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

dat-middleware

Package Overview
Dependencies
Maintainers
1
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.5.9 to 1.5.10

test/setToErr.js

31

lib/RequestData.js

@@ -80,2 +80,5 @@ var error = require('./error');

};
RequestData.prototype.execErr = function (err, req, res, next) {
this.exec(req, res, next, err);
};
/**

@@ -86,2 +89,3 @@ * @method

var self = this;
var mwErr = arguments[3]; // hack, cant accept 4 args else middleware will be considered errorHandler
var errors = [];

@@ -107,3 +111,3 @@ if (this.nextOnFirstError) {

else if (step.type.indexOf('transform') === 0) {
self._transformStep(req, step);
self._transformStep(step, req, mwErr);
}

@@ -122,3 +126,3 @@ else {

else if (step.type.indexOf('transform') === 0) {
self._transformStep(req, step);
self._transformStep(step, req, mwErr);
}

@@ -342,3 +346,3 @@ else {

RequestData.prototype.set = function (key, value) {
return this.transform(function (data, req) {
return this.transform(function (data, req, err) {
data = utils.set(key, value)(data);

@@ -369,2 +373,17 @@ if (typeof key === 'object') {

/**
* set key to err
* @param {key} string - key to set value for or key-value set object
* @param {value} string - value to set for key
* or
* @param {obj} string - key to set value for or key-value set object
*/
RequestData.prototype.setToErr = function (key) {
this.transform(function (data, req, err) {
data[key] = err;
return data;
});
return this.execErr.bind(this);
};
/*************** CONDITIONALS ***************/

@@ -447,3 +466,3 @@ /*************** CONDITIONALS ***************/

};
RequestData.prototype._transformStep = function (req, step) {
RequestData.prototype._transformStep = function (step, req, err) {
if (step.type === 'transform') {

@@ -455,3 +474,3 @@ var keypath = this.keypath.bind(this);

.map(reqValueForKeypath)
.map(bindRight(step.transformation, req))
.map(bindRight(step.transformation, req, err))
.forEach(setValueForKey);

@@ -461,3 +480,3 @@ }

var dataType = this.dataType;
req[dataType] = step.transformation(req[dataType], req);
req[dataType] = step.transformation(req[dataType], req, err);
}

@@ -464,0 +483,0 @@ else {

2

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

@@ -5,0 +5,0 @@ "main": "index.js",

var express = require('express');
var mw = require('../../index');
var next = function (req, res, next) {next();}
var next = function (req, res, next) {next();};

@@ -5,0 +5,0 @@ module.exports = function createAppWithMiddleware (middleware, middleware2, middleware3) {

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