# uplo.js

> Node wrapper for uplod of the Uplo network

Latest version **1.0.2** (published 2021-02-14) · MIT license · 0 weekly downloads

## Install

```sh
npm install uplo.js
pnpm add uplo.js
yarn add uplo.js
bun add uplo.js
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.2 |
| Published | 2021-02-14 |
| First published | 2021-02-14 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 2 |
| Unpacked size | 22.9 KB |
| Known vulnerabilities | 0 (+1 in 1 direct dependencies) |
| Install scripts | no |
| Author | David Gilbert |
| Maintainers | davidmgilbert |
| Keywords | uplo, uplo-ui, Decentralized, Cloud, Storage, Altcoin, Cryptocurrency |

## Links

- npm: https://www.npmjs.com/package/uplo.js
- Repository: https://github.com/uplo-tech/nodejs-uplo
- Issues: https://github.com/uplo-tech/issues
- npm.io page: https://npm.io/package/uplo.js

## Dependencies (2)

- [request](https://npm.io/package/request.md) ^2.81.0
- [bignumber.js](https://npm.io/package/bignumber.js.md) ^4.0.4

## Alternatives

- [localforage](https://npm.io/package/localforage.md) — 6.2M weekly downloads
- [localforage-observable](https://npm.io/package/localforage-observable.md) — 30.8K weekly downloads
- [@y/y](https://npm.io/package/@y/y.md) — 30.1K weekly downloads
- [@metaobjectsdev/render](https://npm.io/package/@metaobjectsdev/render.md) — 3.5K weekly downloads
- [@ledgerhq/coin-algorand](https://npm.io/package/@ledgerhq/coin-algorand.md) — 1.1K weekly downloads

## Recent versions

- 1.0.2 (latest) — 2021-02-14
- 1.0.1 — 2021-02-14

## README

# [![Uplo Logo](http://uplo.tech/img/svg/uplo-green-logo.svg)](http://uplo.tech/) Nodejs Wrapper

[![Build Status](https://travis-ci.org/NebulousLabs/Nodejs-Uplo.svg?branch=master)](https://travis-ci.org/NebulousLabs/Nodejs-Uplo)
[![js-standard-style](https://img.shields.io/badge/code%20style-standard-brightgreen.svg)](http://standardjs.com/)
[![devDependency Status](https://david-dm.org/NebulousLabs/Nodejs-Uplo/dev-status.svg)](https://david-dm.org/NebulousLabs/Nodejs-Uplo#info=devDependencies)
[![dependencies Status](https://david-dm.org/NebulousLabs/Nodejs-Uplo.svg)](https://david-dm.org/NebulousLabs/Nodejs-Uplo#info=dependencies)
[![license:mit](https://img.shields.io/badge/license-mit-blue.svg)](https://opensource.org/licenses/MIT)

# A Highly Efficient Decentralized Storage Network

This is a [Nodejs](https://nodejs.org/) wrapper for
[Uplo](https://github.com/NebulousLabs/Uplo). Use it in your apps to easily
interact with the Uplo storage network via function calls instead of manual http
requests.

## Prerequisites

- [node & npm (version 5.9.0+ recommended)](https://nodejs.org/download/)

## Installation

```
npm install uplo.js
```

## Example Usage

```js
import { connect } from 'uplo.js'

// Using promises...
// connect to an already running Uplo daemon on localhost:8480 and print its version
connect('localhost:8480')
  .then((uplod) => {
    uplod.call('/daemon/version').then((version) => console.log(version))
  })
  .catch((err) => {
    console.error(err)
  })

// Or ES7 async/await
async function getVersion() {
  try {
    const uplod = await connect('localhost:8480')
    const version = await uplod.call('/daemon/version')
    console.log('Uplod has version: ' + version)
  } catch (e) {
    console.error(e)
  }
}

```
You can also forgo using `connect` and use `call` directly by providing an API address as the first parameter:

```js
import { call } from 'uplo.js'

async function getVersion(address) {
  try {
    const version = await call(address, '/daemon/version')
    return version
  } catch (e) {
    console.error('error getting ' + address + ' version: ' + e.toString())
  }
}

console.log(getVersion('10.0.0.1:8480'))
```

`uplo.js` can also launch a uplod instance given a path on disk to the `uplod` binary.  `launch` takes an object defining the flags to use as its second argument, and returns the `child_process` object.  You are responsible for keeping track of the state of this `child_process` object, and catching any errors `launch` may throw.

```js
import { launch } from 'uplo.js'

try {
  // Flags are passed in as an object in the second argument to `launch`.
  // if no flags are passed, the default flags will be used.
  const uplodProcess = launch('/path/to/your/uplod', {
    'modules': 'cghmrtw',
    'profile': true,
  })
  // uplodProcess is a ChildProcess class.  See https://nodejs.org/api/child_process.html#child_process_class_childprocess for more information on what you can do with it.
  uplodProcess.on('error', (err) => console.log('uplod encountered an error ' + err))
} catch (e) {
  console.error('error launching uplod: ' + e.toString())
}
```

The call object passed as the first argument into call() are funneled directly
into the [`request`](https://github.com/request/request) library, so checkout
[their options](https://github.com/request/request#requestoptions-callback) to
see how to access the full functionality of [Uplo's
API](https://github.com/NebulousLabs/Uplo/blob/master/doc/API.md)

```js
Uplod.call({
  url: '/consensus/block',
  method: 'GET',
  qs: {
    height: 0
  }
})
```

Should log something like:

```bash
null { block:
 { parentid: '0000000000000000000000000000000000000000000000000000000000000000',
   nonce: [ 0, 0, 0, 0, 0, 0, 0, 0 ],
   timestamp: 1433600000,
   minerpayouts: null,
   transactions: [ [Object] ] } }
```

---
_Source: https://npm.io/package/uplo.js · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
