# mist-api

> Mist API wrapper for node. Used for accessing all Mist APIs.

Latest version **0.13.3** (published 2020-01-02) · SEE LICENSE IN LICENSE license · 0 weekly downloads

## Install

```sh
npm install mist-api
pnpm add mist-api
yarn add mist-api
bun add mist-api
```

## Health

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

Positive: no vulnerabilities.

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

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.13.3 |
| Published | 2020-01-02 |
| First published | 2017-01-25 |
| Weekly downloads | 0 |
| License | SEE LICENSE IN LICENSE |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 3 |
| Unpacked size | 2 MB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | André Kaustell |
| Maintainers | akaustel, janyman, kristianb |
| Keywords | mist, api, iot, security, peer-to-peer |

## Links

- npm: https://www.npmjs.com/package/mist-api
- Repository: foremost.controlthings.fi:/ct/mist/mist-node-api-node
- npm.io page: https://npm.io/package/mist-api

## Dependencies (3)

- [nan](https://npm.io/package/nan.md) 2.13.2
- [node-gyp](https://npm.io/package/node-gyp.md) ^3.8.0
- [bson-buffer](https://npm.io/package/bson-buffer.md) 1.0.2

## Recent versions

- 0.13.3 (latest) — 2020-01-02
- 0.13.2 — 2019-12-19
- 0.13.1 — 2019-09-12
- 0.13.0 — 2019-09-06
- 0.12.3 — 2019-05-21
- 0.12.2 — 2019-05-21
- 0.12.1 — 2019-05-21
- 0.12.0 — 2019-04-24
- 0.10.0-beta-5 — 2019-02-14
- 0.10.0-beta-2 — 2019-02-12
- 0.10.0-beta-1 — 2019-02-11
- 0.4.0-beta-4 — 2018-04-13
- 0.4.0-beta-3 — 2018-04-12
- 0.4.0-beta — 2018-01-13
- 0.0.18 — 2017-03-29
- … 8 more at https://npm.io/package/mist-api/versions

## README

# Mist API

A native node.js plugin which uses the C99 Mist implementation.  Currently working with Linux x86_64 and nodejs v6, v8, v10. To get it working you need to run a Wish Core on the same host.

## Install 

```sh
npm install mist-api
```

## Example

```js
var MistNode = require('mist-api').MistNode;

function Motor() {
    var name = 'Motor';
    var number = 42;

    // create a mist node (with a unique name per wish core)
    var node = new MistNode({ name: name }); // , coreIp: '127.0.0.1', corePort: 9094

    // add `mist` endpoint
    node.addEndpoint('mist', { type: 'string' });
    // add `mist.name` as subendpoint to mist
    node.addEndpoint('mist.name', { type: 'string', read: function(args, peer, cb) { cb(null, name); } });
    
    // add readable and writable `number` endpoint
    node.addEndpoint('number', {
        type: 'float',
        read: function(args, peer, cb) { cb(null, number); },
        write: function(value, peer, cb) {
            // write the internal state variable for `number` endpoint
            number = parseFloat(value);
            // signal successful write
            cb();
            // signal `number` value changed
            node.changed('number');
        }
    });

    // update number every 5 sec
    var interval = setInterval(() => { number++; node.changed('number'); }, 5000);
    
    // add an invokable endpoint
    node.addEndpoint('getLog', {
        type: 'invoke',
        invoke: function(args, peer, cb) {
            cb(null, { dataset: [{ x: 2, y: 45 }, { x: 5, y: 55 }], request: args, requestee: peer });
        }
    });
    
    this.shutdown = function() { clearInterval(interval); node.shutdown(); };
}

// create Motor instance to run
var motor = new Motor();

// clean shutdown:
//   motor.shutdown();
```





### Problems

#### node-gyp fails on c++ compile error  "class v8 has no member IsUint8Array" or similar

This occurs on hosts that have node.js 0.10.x installed as 'nodejs', and
node-gyp. Solution:

This usually occurs on a host with multiple node.js installations, or
if are on a host with an outdated system-wide installation of node.js
(Such as many slightly older Debian installations)

You should use Node version manager (NVM) to install node 6. https://github.com/creationix/nvm 

Then you should switch your session to using node.js 6.x, 8, or 10
and install node-gyp to that instance of node.js:
```
nvm use 6
npm i -g node-gyp 
```

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