From 03a48eeff8c1b754de30f13e8680f9fa66314a00 Mon Sep 17 00:00:00 2001 From: pismenskiy Date: Tue, 1 Mar 2022 16:01:08 +0300 Subject: [PATCH] docs: update docs --- packages/expressjs/README.md | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/packages/expressjs/README.md b/packages/expressjs/README.md index f783631..79a0c9c 100644 --- a/packages/expressjs/README.md +++ b/packages/expressjs/README.md @@ -16,10 +16,20 @@ import { IJsonRpcParams } from 'nestjs-json-rpc' +import { + RpcId, Req, Res, Headers, +} from 'expressjs-json-rpc' + @JsonRpcMiddleware() export class SomeJsonRpcMware { @JsonRpcMethod('some-method') - doSomething(@JsonRpcId() id: IJsonRpcId, @JsonRpcParams() params: IJsonRpcParams) { + doSomething( + @JsonRpcId() id: IJsonRpcId, + @JsonRpcParams() params: IJsonRpcParams, + @Req() req: IRequest, + @Res() res: IRequest, + @Headers() headers: any + ) { const {foo} = params if (foo === 'bar') { @@ -35,5 +45,17 @@ const jsonRpcMware = new SomeJsonRpcMware().middleware app.use('/rpc', jsonRpcMware) ``` +### Decorators +| Param decorator | Value | +|-------------------------|---------------------------------| +| @Req() | req | +| @Res() | res | +| @Next() | next | +| @Body(key?: string) | req.body / req.body[key] | +| @Param(key?: string) | req.params / req.params[key] | +| @Query(key?: string) | req.query / req.query[key] | +| @Headers(name?: string) | req.headers / req.headers[name] | +| @Ip() | req.ip | + ## Specification [https://www.jsonrpc.org/specification](https://www.jsonrpc.org/specification)