The lint middleware aids in middleware development, by performing basic cheques at boot, and during requests. This process currently checks that the:
handle()
is req or requesthandle()
is res or responsehandle()
is nexthandle()
to see if next()
is called, or if the request is responded tomethod
property is always uppercasereq.headers
is accessed with lowercaseThe placement of lint within the stack is important. It should sit below the middleware you are developing, in order to validate during runtime, however it can also simply be placed at the bottom of the stack to validate all middleware statically.
Warning: layer params:0 First parameter should be named req or request, but is undefined
Warning: layer params:0 Second parameter should be named res or response, but is undefined
Warning: layer params:0 Third parameter should be named next, but is undefined
Warning: layer params:0 Does not seem to call next(), or respond to the request
Warning: layer hang:1 Does not seem to call next(), or respond to the request
Warning: layer req.headers:3 Request headers are lowercased, seems to be accessed with capitals
0) params:
function (){
arguments[2]();
}
1) hang:
function (req, res, next){
// Call foo() instead so
// that our demo can still function.
var foo = next;
foo();
// All good
var ct = req.headers['content-type'];
}
3) req.headers:
function (req, res, next){
// Request headers are always normalized as
// lowercased by ryan's http parser.
var ct = req.headers['Content-Type'];
next();
}
Warning: layer method uppercase:4 Request method is no longer uppercase, got get