cookie-screener
v1.0.3
Published
cookie screening with options
Downloads
3
Readme
cookie-screener
Screen req.cookies
with whitelist
or blacklist
mode
Installation
$ npm install cookie-screener
API
const express = require('express');
const cookieParser = require('cookie-parser');
const cookieScreener = require('cookie-screener');
const app = express();
app.use(cookieParser());
app.use(cookieScreener({
mode: 'whitelist', list: ['foo', 'bar']
}));
cookieScreener(options)
options
mode
: {string}'whitelist'
|'blacklist'
list
: {string | array} keys to whitelist or blacklist
Example
const express = require('express');
const cookieParser = require('cookie-parser');
const cookieScreener = require('./index');
const app = express();
app.use(cookieParser());
app.use(cookieScreener({
mode: 'whitelist', list: ['foo', 'bar']
}));
app.post('/', function (req, res) {
// curl http://127.0.0.1:8080 --cookie "foo=foo;bar=bar;zen=zne" -X POST
console.log(JSON.stringify(req.cookies, null, 2));
res.send(req.cookies);
// {
// "foo": "foo",
// "bar": "bar"
// }
});
app.listen(8080);