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

dat-middleware

Package Overview
Dependencies
Maintainers
2
Versions
40
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

dat-middleware - npm Package Compare versions

Comparing version 1.9.0 to 1.9.1

4

package.json
{
"name": "dat-middleware",
"version": "1.9.0",
"version": "1.9.1",
"description": "common request, response, body, query, and param validation, transformation, and flow control middleware",

@@ -40,3 +40,3 @@ "main": "index.js",

"fn-object": "^0.2.2",
"keypather": "^1.7.0",
"keypather": "^1.7.5",
"map-utils": "~0.4.0",

@@ -43,0 +43,0 @@ "middleware-flow": "^0.6.0"

@@ -5,2 +5,3 @@ var createAppWithMiddleware = require('./fixtures/createAppWithMiddleware');

var request = require('./lib/superdupertest');
var keypather = require('keypather')();
var values = function (obj) {

@@ -17,2 +18,4 @@ return Object.keys(obj).map(function (key) {

describe('mw.body(keypath).require()', requireKeypath('body', 'foo.bar.baz'));
describe('mw.body(keys...).require()', requireKeys('body'));

@@ -61,2 +64,36 @@ describe('mw.query(keys...).require()', requireKeys('query'));

function requireKeypath (dataType, keypath) {
return function () {
before(function () {
this.keypath = keypath;
this.app = createAppWithMiddleware(mw[dataType](this.keypath).require());
});
it('should error if required key not included', function (done) {
var body = {};
var query = {};
var params = values({});
request(this.app)
.post('/'+dataType, params, query)
.send(body)
.expect(400)
.expect(function (res) {
res.body.message.should.match(/required/);
})
.end(done);
});
it('should succeed if required key included', function (done) {
var data = {};
keypather.set(data, this.keypath, 'value');
var body = dataType === 'body' ? data : {};
var query = dataType === 'query' ? data : {};
var params = dataType === 'params' ? values(data) : [];
request(this.app)
.post('/'+dataType, params, query)
.send(data)
.expect(200, data)
.end(done);
});
};
}
function requireKeys (dataType) {

@@ -63,0 +100,0 @@ return function () {

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