koa-jsonrpc
Json-RPC 2 middleware implementation on Koa v2
Requirements
- Koa@2+
- Node@8+
Installation
npm install koa-jsonrpc --save
Options
- limit[String] - sets the maximum size allowed for requests
- auth[Object] - requires requests to have a valid HMAC256 of the username and password as its authorization header
Authorization
//generating authorization headerconst crypto = ;const token = cryptoconsole // will print out the token, and you can add this on the header of your request.
Usage
const Koa = ;const app = ;const koaJsonRpc = ;const options = limit: '20mb' // optional, defaults to 1mb auth: // optional, will require authorization header username: 'myuser' password: 'mypass' const jrpc2 = ; // Add methodsjrpc2; jrpc2; jrpc2; app;