Convert query strings to boolean, numbers and dates for express/connect applications.
npm install --save express-query-boolean
The module will recursively attempt to parse every property in req.query
.
Load it right after bodyParser
:
var autoParser = require('express-query-auto-parse');
// [...]
app.use(bodyParser.json());
app.use(autoParser());
// ?a=true&b[c]=false
console.log(req.query);
// => { a: 'true', b: { c: 'false' } }
// ?a=true&b[c]=false
console.log(req.query);
// => { a: true, b: { c: false } }
Convert string to numbers if they can be converted.
// ?a=2a&b=2
console.log(req.query);
// => { a: '2a', b: 2 }
Convert string to dates if they are valid dates.
// ?a=2a&b=2020-03-17T23:05:53.733Z
console.log(req.query);
// => { a: '2a', b: 2020-03-17T23:05:53.733Z }
- FIX - Documentation
- Added support for date conversion.
- FIX - Vulns and outdatet packages.
- FIX - Travis integration shows wrong build.
- FIX - NPM tag show wrong info.
- README updated
Copyright (c) 2015 Marius Craciunoiu. Licensed under the MIT license.