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.6.1 to 1.7.0

test/.matches.js.un~

5

lib/RequestData.js

@@ -417,4 +417,2 @@ var error = require('./error');

var dataTypeRE = new RegExp('^'+this.dataType+'.');
var filter = this.required ?
returnTrue : reqValueNotUndefined;
if (this.orTheValidations) {

@@ -425,4 +423,3 @@ return step.validate(req);

var keypaths = this._keys
.map(keypath)
.filter(filter);
.map(keypath);
keypaths

@@ -429,0 +426,0 @@ .map(reqValueForKeypath)

7

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

@@ -27,2 +27,5 @@ "main": "index.js",

"author": "Tejesh Mehta",
"contributors": [
"Bryan Kendall <bryan@bryankendall.com>"
],
"license": "MIT",

@@ -40,3 +43,3 @@ "bugs": {

"map-utils": "~0.4.0",
"middleware-flow": "^0.4.1"
"middleware-flow": "^0.5.0"
},

@@ -43,0 +46,0 @@ "devDependencies": {

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

});
describe('only then, failing', function () {
before(function () {
this.app = createAppWithMiddleware(
mw.body('nonexistant').require()
.then(appendReqBody('key', '3'))
);
});
it('should not execute "then-middlewares" the validation passes', function (done) {
request(this.app)
.post('/body')
.send({ key: 'val' })
.expect({ key: 'val' })
.end(done);
});
});
describe('match, only then, failing', function () {
before(function () {
this.app = createAppWithMiddleware(
mw.body('nonexistant').matches(/^nope$/)
.then(appendReqBody('key', '3'))
);
});
it('should not execute "then-middlewares" the validation passes', function (done) {
request(this.app)
.post('/body')
.send({ key: 'val' })
.expect({ key: 'val' })
.end(done);
});
});
describe('else', function () {

@@ -53,2 +83,2 @@ before(function () {

});
});
});

@@ -20,2 +20,4 @@ var express = require('express');

middleware,
middleware2,
middleware3,
mw.body().send());

@@ -25,2 +27,4 @@ app.all('/query',

middleware,
middleware2,
middleware3,
mw.query().send());

@@ -30,2 +34,4 @@ app.all('/headers',

middleware,
middleware2,
middleware3,
mw.headers().send());

@@ -35,2 +41,4 @@ app.all('/params/:key1?/:key2?/:key3?/:key4?/:key5?',

middleware,
middleware2,
middleware3,
mw.params().send());

@@ -37,0 +45,0 @@ return app;

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

});
it('should succeed if key does not exist', function (done) {
it('should fail if key does not exist', function (done) {
var data = {};

@@ -72,4 +72,3 @@ var body = dataType === 'body' ? data : {};

.send(body)
.expect(200)
.expect(checkResponseMatch(dataType, headers, data))
.expect(400)
.end(done);

@@ -89,3 +88,3 @@ });

}
}
};
}

@@ -99,3 +98,3 @@

});
it('should succeed if all keys are not included', function (done) {
it('should fail if all keys are not included', function (done) {
var data = {};

@@ -110,4 +109,3 @@ var body = dataType === 'body' ? data : {};

.send(body)
.expect(200)
.expect(checkResponseMatch(dataType, headers, data))
.expect(400)
.end(done);

@@ -140,3 +138,3 @@ });

.expect(function (res) {
res.body.message.should.match(new RegExp(keys[1]));
res.body.message.should.match(new RegExp(keys[0]));
res.body.message.should.match(reRE);

@@ -143,0 +141,0 @@ })

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

});
it('should succeed if key does not exist', function (done) {
it('should fail if key does not exist', function (done) {
var data = {};

@@ -76,3 +76,3 @@ var body = dataType === 'body' ? data : {};

.send(body)
.expect(200, data)
.expect(400)
.end(done);

@@ -89,3 +89,3 @@ });

});
it('should succeed if all keys are not included', function (done) {
it('should fail if all keys are not included', function (done) {
var data = {};

@@ -98,3 +98,3 @@ var body = dataType === 'body' ? data : {};

.send(body)
.expect(200, data)
.expect(400)
.end(done);

@@ -127,3 +127,3 @@ });

.expect(function (res) {
res.body.message.should.match(new RegExp(keys[1]));
res.body.message.should.match(new RegExp(keys[0]));
res.body.message.should.match(typeRE);

@@ -150,2 +150,2 @@ })

};
}
}

Sorry, the diff of this file is not supported yet

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