express-json-rpc-router
Advanced tools
Comparing version 0.3.2 to 1.0.0
19
index.js
@@ -32,3 +32,3 @@ /*! | ||
async function handleSingleReq(body) { | ||
const { id, method, jsonrpc } = body | ||
const { id, method, jsonrpc, params } = body | ||
try { | ||
@@ -39,7 +39,7 @@ validateJsonRpcVersion(jsonrpc, VERSION) | ||
if (beforeMethod = (config.beforeMethods[method])) await executeHook(beforeMethod, body.params) | ||
if (beforeMethod = (config.beforeMethods[method])) await executeHook(beforeMethod, params) | ||
const result = await config.methods[method](body) | ||
const result = await config.methods[method](params) | ||
if (afterMethod = (config.afterMethods[method])) await executeHook(afterMethod, body.params, result) | ||
if (afterMethod = (config.afterMethods[method])) await executeHook(afterMethod, params, result) | ||
@@ -49,10 +49,7 @@ if (!isNil(id) ) return { jsonrpc, result, id } | ||
if (isFunction(config.onError)) config.onError(err, body) | ||
return { | ||
jsonrpc: VERSION, | ||
error: { | ||
code: Number(err.code || err.status || INTERNAL_ERROR.code), | ||
message: err.message || INTERNAL_ERROR.message | ||
}, | ||
id: id || null | ||
const error = { | ||
code: Number(err.code || err.status || INTERNAL_ERROR.code), | ||
message: err.message || INTERNAL_ERROR.message | ||
} | ||
return { jsonrpc, error, id: id || null } | ||
} | ||
@@ -59,0 +56,0 @@ } |
{ | ||
"name": "express-json-rpc-router", | ||
"description": "Json-rpc middleware router for express", | ||
"version": "0.3.2", | ||
"version": "1.0.0", | ||
"author": "Valerii Kuzivanov <valerii.kuzivanov@gmail.com>", | ||
@@ -6,0 +6,0 @@ "license": "MIT", |
@@ -14,3 +14,3 @@ # JSON-RPC node.js implementation | ||
```sh | ||
$ npm install body-parser express-json-rpc-router | ||
$ npm install express express-json-rpc-router | ||
``` | ||
@@ -20,3 +20,3 @@ or | ||
```sh | ||
$ yarn add body-parser express-json-rpc-router | ||
$ yarn add express express-json-rpc-router | ||
``` | ||
@@ -30,5 +30,5 @@ | ||
```js | ||
const app = require('express')() | ||
const bodyParser = require('body-parser') | ||
const express = require('express') | ||
const jsonRouter = require('express-json-rpc-router') | ||
const app = express() | ||
@@ -42,3 +42,3 @@ const controller = { | ||
app.use(bodyParser.json()) | ||
app.use(express.json()) | ||
app.use(jsonRouter({ methods: controller })) | ||
@@ -45,0 +45,0 @@ app.listen(3000, () => console.log('Example app listening on port 3000')) |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
0
11982
200