dat-middleware
Advanced tools
Comparing version 1.5.7 to 1.5.8
@@ -14,2 +14,3 @@ var RequestData = require('./lib/RequestData'); | ||
mw.params = require('./lib/params'); | ||
mw.log = require('./lib/log'); | ||
mw.errorHandler= require('./lib/errorHandler'); |
@@ -1,26 +0,3 @@ | ||
var isString = require('101/is-string'); | ||
var exists = require('101/exists'); | ||
var keypather = require('keypather')(); | ||
var replaceKeypaths = require('./utils/replaceKeypaths'); | ||
function replaceKeypaths (req, args, dontReplace) { | ||
return args.map(function (arg) { | ||
var kpArgs; | ||
if (isString(arg)) { | ||
kpArgs = [arg]; | ||
} | ||
else if (Array.isArray(arg)) { | ||
kpArgs = arg; | ||
} | ||
else { | ||
return arg; | ||
} | ||
if (!dontReplace && kpArgs.length>1) { | ||
kpArgs = [kpArgs[0]].concat(replaceKeypaths(req, kpArgs.slice(1), true)); | ||
} | ||
kpArgs = [req].concat(kpArgs); | ||
var keypathVal = keypather.get.apply(keypather, kpArgs); | ||
return exists(keypathVal) ? keypathVal : arg; | ||
}); | ||
} | ||
var endMethods = ['send', 'json', 'end', 'redirect']; | ||
@@ -27,0 +4,0 @@ function middlewarizeResMethod (method) { |
{ | ||
"name": "dat-middleware", | ||
"version": "1.5.7", | ||
"version": "1.5.8", | ||
"description": "common request, response, body, query, and param validation, transformation, and flow control middleware", | ||
@@ -50,4 +50,5 @@ "main": "index.js", | ||
"fn-object": "^0.2.1", | ||
"clone": "^0.1.11" | ||
"clone": "^0.1.11", | ||
"function-proxy": "~0.5.1" | ||
} | ||
} |
var express = require('express'); | ||
var mw = require('../../index'); | ||
var next = function (req, res, next) {next();} | ||
module.exports = function createAppWithMiddleware (middleware, middleware2) { | ||
middleware2 = middleware2 || function (req, res, next) {next();}; | ||
module.exports = function createAppWithMiddleware (middleware, middleware2, middleware3) { | ||
middleware2 = middleware2 || next; | ||
middleware3 = middleware3 || next; | ||
var app = express(); | ||
@@ -13,3 +15,4 @@ app.use(express.json()); | ||
middleware, | ||
middleware2); | ||
middleware2, | ||
middleware3); | ||
app.all('/body', | ||
@@ -16,0 +19,0 @@ // inspect, |
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
64262
29
1754
9