express-query-date
Convert query strings to dates for express/connect applications.
Installation
npm install --save express-query-date
Getting Started
The module will recursively attempt to parse every property in req.query
.
Load it right after bodyParser
:
var dateParser = ; // [...] app;app;
Without
// ?a=2015-01-01T05:00:00.000Z&b[c]=2015-01-01T05:00:00.000Zconsole;// => { a: '2015-01-01T05:00:00.000Z', b: { c: '2015-01-01T05:00:00.000Z' } }
With
// ?a=2015-01-01T05:00:00.000Z&b[c]=2015-01-01T05:00:00.000Zconsole;// => { a: Date 2015-01-01T05:00:00.000Z, b: { c: Date 2015-01-01T05:00:00.000Z } }
Formats
Default:
'x' momentISO_8601
To use your own, provide them when initializing the module:
app;
See moment.js documentation for more.
Strict Mode
Strict format matching is on by default. To disable this, set options.strict
to false when initializing the module.
app;
License
Copyright (c) 2015 Marius Craciunoiu. Licensed under the MIT license.