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

1.0.14 • Public • Published

@qiwi/json-rpc

JSON RPC 2.0 Controller

Install

yarn add @qiwi/json-rpc
npm add @qiwi/json-rpc

Usage

import {
  JsonRpcMiddleware,
  JsonRpcMethod,
  IJsonRpcId,
  IJsonRpcParams
} from '@qiwi/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

Versions

Current Tags

VersionDownloads (Last 7 Days)Tag
1.0.140latest

Version History

VersionDownloads (Last 7 Days)Published
1.0.140
1.0.130
1.0.120
1.0.110
1.0.100
1.0.90
1.0.81
1.0.70
1.0.60
1.0.51
1.0.40
1.0.30
1.0.20
1.0.10
1.0.00

Package Sidebar

Install

npm i @qiwi/json-rpc

Weekly Downloads

2

Version

1.0.14

License

MIT

Unpacked Size

11 kB

Total Files

13

Last publish

Collaborators

  • antongolub
  • qiwibot