express-content-length-validator
Make sure your application is not vulnerable to large payload attacks
install
$ npm install express-content-length-validator --save
api
Once you've gotten the content-length module:
var contentLength = ;
You'll have a single function to work with: validateMax
.
contentLength.validateMax(options)
options
is an object with three properties:
max
, which defaults to 999;status
, which defaults to 400;message
, which defaults to "Invalid payload; too big.".
usage as a middleware
var contentLength = ; var app = ; var MAX_CONTENT_LENGTH_ACCEPTED = 9999; app; // max size accepted for the content-length // and then, when you're checking the routes app ; app;
usage per endpoint
var contentLength = ; var app = ; var MAX_CONTENT_LENGTH_ACCEPTED = 9999; app; app;
It's that easy =]
license
MIT