express uses the qs module to parse query strings but it seems to send everything as a string.
How do I get number and boolean values?
app?flag=true&count=20
// => in express gives:
req.query.count === "20"
req.query.flag === "true"
// => whereas I want
req.query.count === 20 // number (int)
req.query.flag === true // boolean
both of those query params get parsed as strings, which is really annoying to have to do all my own typechecking, parseInt etc. and casting. Is there perhaps a lib that would take care of the resulting object?
Other qs libraries seem to also eschew this simple case although they're great at deeply nested objects encoded on the URL...
https://www.npmjs.com/package/query-string
queryString.parse('foo[0]=1&foo[1]=2&foo[3]=3', {arrayFormat: 'index'});
//=> {foo: ['1', '2', '3']}
Multiple types in query string in nodejs req.params.number is string in expressjs? https://github.com/cdeutsch/query-string-for-all https://www.npmjs.com/package/url-parse