
Security News
Attackers Are Hunting High-Impact Node.js Maintainers in a Coordinated Social Engineering Campaign
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.
simple-query-parser
Advanced tools
This module is a simple query parser which can handle different operator.
First install the package
npm i --save query-parser
Then you can start using the module
const queryParser = require('simple-query-parser')
// ...
This module needs an object with parsed queries. With express, you can get it in req.query.
For example, the following route
https://mywebsite.com/product?price=lte:25&orderBy=recent&page=3
would be translate by express in
let queryParams = {
price: 'lte:25',
orderBy: 'recent',
page: '3'
}
And than translate by query parser like this:
const queryParser = require('query-parser')
let parsedParams = queryParser.parse(queryParams)
// parseParams contains
[{
key: 'price',
value: 25,
comparator: '<='
}, {
key: 'orderBy',
value: 'recent',
comparator: '='
}, {
key: 'page',
value: 3,
comparator: '='
}]
If your values could be convert to int or float number, query-parser will do it automatically.
Simple query parser also handle arrays.
In the URL, add a coma between all your values and this will generate an array.
https://mywebsite.com/product?type=white,yellow,pink
With this URL, query parser will return the following object:
const queryParser = require('query-parser')
let parsedParams = queryParser.parse(queryParams)
// parseParams contains
[{
key: 'type',
value: ['white', 'yellow', 'pink'],
comparator: 'in'
}]
Here is the list of comparator.
lte -> <=
lt -> <
gte -> >=
gt -> >
df -> !=
eq -> =
lk -> LIKE
Note: If you choose to use the lk comparator, a % will be added on both side of your value.
Your keys can only contains letter or number, if there are special caracters in it, it will be skipped.
This route
https://mywebsite.com/product?order;By=recent&page=3
will at the end be transformed in this array.
[{
key: 'page',
value: 3,
comparator: '='
}]
FAQs
Simple query parser
We found that simple-query-parser demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.

Security News
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.

Security News
Node.js has paused its bug bounty program after funding ended, removing payouts for vulnerability reports but keeping its security process unchanged.