0.0.4 • Published 6 years ago

@c3-labs/c3-sdk-js v0.0.4

Weekly downloads
1
License
MIT
Repository
github
Last release
6 years ago

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