json-rpc-engine
Advanced tools
Comparing version 3.6.0 to 3.6.1
{ | ||
"name": "json-rpc-engine", | ||
"version": "3.6.0", | ||
"version": "3.6.1", | ||
"description": "a tool for processing JSON RPC", | ||
@@ -9,3 +9,3 @@ "main": "src/index.js", | ||
"build": "aegir build", | ||
"test": "aegir test", | ||
"test": "npm run test:node", | ||
"test:node": "aegir test --target node", | ||
@@ -12,0 +12,0 @@ "test:browser": "aegir test --target browser", |
'use strict' | ||
const async = require('async') | ||
const JsonRpcError = require('json-rpc-error') | ||
@@ -39,5 +38,4 @@ class RpcEngine { | ||
this._runMiddleware(req, res, (err) => { | ||
if (err) return cb(err) | ||
// return response | ||
cb(null, res) | ||
cb(err, res) | ||
}) | ||
@@ -109,3 +107,6 @@ } | ||
// prepare error message | ||
res.error = new JsonRpcError.InternalError(err) | ||
res.error = { | ||
code: err.code || -32603, | ||
message: err.stack, | ||
} | ||
// return error-first and res with err | ||
@@ -112,0 +113,0 @@ return onDone(err, res) |
@@ -67,2 +67,19 @@ /* eslint-env mocha */ | ||
it('erroring middleware test', function (done) { | ||
let engine = new RpcEngine() | ||
engine.push(function (req, res, next, end) { | ||
end(new Error('no bueno')) | ||
}) | ||
let payload = { id: 1, jsonrpc: '2.0', method: 'hello' } | ||
engine.handle(payload, function (err, res) { | ||
assert(err, 'did error') | ||
assert(res, 'does have response') | ||
assert(res.error, 'does have error on response') | ||
done() | ||
}) | ||
}) | ||
it('empty middleware test', function (done) { | ||
@@ -69,0 +86,0 @@ let engine = new RpcEngine() |
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
20886
559