@knowledgr/koa-jsonrpc
TypeScript icon, indicating that this package has built-in type declarations

1.1.7 • Public • Published

@knowledgr/koa-jsonrpc

Build status: CircleCI

Spec compliant JSON RPC Server middleware for Koa

const Koa = require('koa')
const {JsonRpc} = require('@knowledgr/koa-jsonrpc')

const rpc = new JsonRpc()
rpc.register('my_method', async (foo, bar) => {
    return foo + bar
})

const app = new Koa()
app.use(rpc.middleware)
app.listen(8080)
$ curl -X POST -d '{"id":1,"jsonrpc":"2.0","method":"my_method","params":["honkey","tonk"]}' localhost:8080
{"jsonrpc":"2.0","id":1,"result":"honkeytonk"}

/@knowledgr/koa-jsonrpc/

    Package Sidebar

    Install

    npm i @knowledgr/koa-jsonrpc

    Weekly Downloads

    0

    Version

    1.1.7

    License

    MIT

    Unpacked Size

    24.3 kB

    Total Files

    12

    Last publish

    Collaborators

    • oleg-norestlabs
    • gedanziger
    • knowledgrpatrick