Skip to content
This repository has been archived by the owner on May 24, 2022. It is now read-only.

opennetsys/c3-sdk-js

Repository files navigation

c3-sdk-js

The C3 SDK for NodeJS

License JavaScript Style Guide Build Status Coverage Status

Usage

Here's a hello world example:

const c3 = require('c3-sdk-js')

const client = new c3.Client()

class App {
  setItem (key, value) {
    client.state().set(Buffer.from(key), Buffer.from(value))
  }

  getItem (key) {
    const { value, found } = client.state().get(Buffer.from(key))
    if (!found) {
      return ''
    }

    return value.toString()
  }
}

function main () {
  const app = new App()
  client.registerMethod('setItem', ['string', 'string'], app.setItem)
  client.registerMethod('getItem', ['string'], app.getItem)
  client.serve()
}

main()

Test

make test

Development

Lint

make lint/fix

TODO

  • Use TypeScript

License

MIT