@qiwi/json-rpc-open-rpc
TypeScript icon, indicating that this package has built-in type declarations

1.1.5 • Public • Published

expressjs-json-rpc

Expressjs JSON RPC 2.0 Controller

Install

yarn add expressjs-json-rpc
npm add expressjs-json-rpc

Usage

import {
  JsonRpcMiddleware,
  JsonRpcMethod,
  IJsonRpcId,
  IJsonRpcParams
} from 'nestjs-json-rpc'

@JsonRpcMiddleware()
export class SomeJsonRpcMware {
  @JsonRpcMethod('some-method')
  doSomething(@JsonRpcId() id: IJsonRpcId, @JsonRpcParams() params: IJsonRpcParams) {
    const {foo} = params
    
    if (foo === 'bar') {
      return new JsonRpcError(-100, '"foo" param should not be equal "bar"')
    }
    
    return 'ok'
  }
} 

const jsonRpcMware = new SomeJsonRpcMware().middleware

app.use('/rpc', jsonRpcMware)

Specification

https://www.jsonrpc.org/specification

Readme

Keywords

Package Sidebar

Install

npm i @qiwi/json-rpc-open-rpc

Weekly Downloads

0

Version

1.1.5

License

MIT

Unpacked Size

8.39 kB

Total Files

13

Last publish

Collaborators

  • antongolub
  • qiwibot