Socket
Socket
Sign inDemoInstall

express-json-rpc-router

Package Overview
Dependencies
Maintainers
1
Versions
12
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

express-json-rpc-router - npm Package Compare versions

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'))

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc