warder
v0.0.6
Published
Lightweight request params and headers check middleware for express 4
Downloads
5
Maintainers
Readme
Warder
Lightweight request control middleware for express 4
You can control requests headers, params and bodies easily with warder.
Getting Started
First step install module and save into your dependencies.
Install via NPM
Open terminal and write below line for installation.
npm install warder --save
After you completed install, define warder in your app.
Express Integration
You should define warder in file which handle requests.
var express = require('express');
var app = express();
var warder = require('warder');
app.get('/path', warder(controlType, paramsArray), callbackFunction)
var callbackFunction = function (req, res, next) {
// do somethings here
}
Don't forget! Second argument must be an array.
Check Request Headers
app.get('/users', warder('headers',['token','ipAddr']), callbackFunction)
Check Request Body
app.post('/users', warder('body',['username','email']), callbackFunction)
Check Request Query Params
app.get('/search', warder('query',['q','p']), callbackFunction)
When request don't provide your requirements warder send response like below:
{
"error": true,
"message": "Required fields not provided: username, password"
}
If you have an idea or find error please entry issue.