jackypan1989 / express-query-parser Goto Github PK
View Code? Open in Web Editor NEWA query parser for express.js which helps you parse null and boolean value.
Home Page: https://www.npmjs.com/package/express-query-parser
License: MIT License
A query parser for express.js which helps you parse null and boolean value.
Home Page: https://www.npmjs.com/package/express-query-parser
License: MIT License
no support for it? :)
btw package is outdated too
I have encountered the following case:
filter[id_test][type]=in&filter[id_test][filter][0]=1&filter[id_test][filter][1]=2&filter[id_test][filter][2]=3&filter[id_test][filter][3]=4&filter[id_test][filter][4]=5&filter[id_test][filter][5]=6&filter[id_test][filter][6]=7&filter[id_test][filter][7]=8&filter[id_test][filter][8]=9
Should be parsed to { type: 'in', filter: [1,2,3,4,5,6,7,8,9]},
Instead i get filter: {0:0, 1:1, 2:2, ... 9:9}
Thx for library man.
I have an issue with integration into inversify stack
Code
import queryParser from 'express-query-parser'
...
inversifyExpressServer.setConfig(async (app: express.Application) => {
...
app.use(
queryParser({
parseNull: true,
parseBoolean: true
})
)
});
Error
[2020-11-17T15:51:48.899] [ERROR] main - TypeError: express_query_parser_1.default is not a function
at ...\backend\typescript\src\App.ts:110:28
at InversifyExpressServer.build ...\backend\node_modules\inversify-express-utils\lib\server.js:119:28)
at ...\typescript\src\App.ts:127:41
at processTicksAndRejections (internal/process/task_queues.js:97:5) (<anonymous> ..\App.ts:99:27)
P.S.
you need to add the if (target === '') { to your code.
export const parse = (target: ParsedQuery, options: Options): ParsedQuery => {
switch (typeof target) {
case 'string':
if (target === '') {
return '';
} else if (options.parseNull && target === 'null') {
return null;
Hey there,
Thanks for useful helper package
Docs says that all options are "true" by default, which means that I can use it like this:
app.use(queryParser());
but I can't because of typescript, and passing empty object resetting options to undefined โพ false
Made queryParser
argument optional, and set all options to true by default.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.