Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

json-rpc-engine

Package Overview
Dependencies
Maintainers
1
Versions
36
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

json-rpc-engine - npm Package Compare versions

Comparing version 2.0.0 to 2.1.0

2

lib/asMiddleware.js

@@ -8,3 +8,3 @@ module.exports = asMiddleware

// copy engine result onto response
res.result = engineRes.result
Object.assign(res, engineRes)
end()

@@ -11,0 +11,0 @@ })

{
"name": "json-rpc-engine",
"version": "2.0.0",
"version": "2.1.0",
"description": "a tool for processing JSON RPC",
"main": "index.js",
"scripts": {
"test": "node test/basic.js"
"test": "node test/index.js"
},

@@ -9,0 +9,0 @@ "author": "",

@@ -53,8 +53,10 @@ # RpcEngine

RpcEngines can be nested by converting them to middleware `engine.asMiddleware()`
RpcEngines can be nested by converting them to middleware `asMiddleware(engine)`
```js
const asMiddleware = require('json-rpc-engine/lib/asMiddleware')
let engine = new RpcEngine()
let subengine = new RpcEngine()
engine.push(subengine.asMiddleware())
engine.push(asMiddleware(subengine))
```

@@ -61,0 +63,0 @@

@@ -17,3 +17,3 @@ const RpcEngine = require('../index.js')

engine.push(asMiddleware(engine))
engine.push(asMiddleware(subengine))

@@ -32,1 +32,56 @@ let payload = { id: 1, jsonrpc: '2.0', method: 'hello' }

})
test('asMiddleware - decorate res', function(t){
let engine = new RpcEngine()
let subengine = new RpcEngine()
let originalReq = undefined
subengine.push(function(req, res, next, end){
originalReq = req
res.xyz = true
end()
})
engine.push(asMiddleware(subengine))
let payload = { id: 1, jsonrpc: '2.0', method: 'hello' }
engine.handle(payload, function(err, res){
t.ifError(err, 'did not error')
t.ok(res, 'has res')
t.equals(originalReq.id, res.id, 'id matches')
t.equals(originalReq.jsonrpc, res.jsonrpc, 'jsonrpc version matches')
t.ok(res.xyz, 'res non-result prop was transfered')
t.end()
})
})
test('asMiddleware - decorate req', function(t){
let engine = new RpcEngine()
let subengine = new RpcEngine()
let originalReq = undefined
subengine.push(function(req, res, next, end){
originalReq = req
req.xyz = true
end()
})
engine.push(asMiddleware(subengine))
let payload = { id: 1, jsonrpc: '2.0', method: 'hello' }
engine.handle(payload, function(err, res){
t.ifError(err, 'did not error')
t.ok(res, 'has res')
t.equals(originalReq.id, res.id, 'id matches')
t.equals(originalReq.jsonrpc, res.jsonrpc, 'jsonrpc version matches')
t.ok(originalReq.xyz, 'req prop was transfered')
t.end()
})
})
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