New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

express-query-parser

Package Overview
Dependencies
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

express-query-parser

A parser helps you parse request for your express server

  • 1.3.3
  • latest
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

Express-query-parser

A parser helps you parse request for your express server. You may usually encounter some req.query issues like parsing 'null', 'true' and any numbered string. This parser covert them to the right type.

scenarios

query with object

// GET http://localhost/?a=null&b=true&c[d]=false&c[e]=3.14

// without this parser
req.query = {a: 'null', b: 'true', c: {d: 'false', e: '3.14'}}

// with this parser
req.query = {a: null, b: true, c: {d: false, e: 3.14}}

query with array

// GET http://localhost/?a[]=null&a[]=false

// without this parser
req.query = {a: ['null', 'false']}

// with this parser
req.query = {a: [null, false]}

changelog

2022-05-31 (1.3.3): add empty string convert
2021-11-30 (1.3.2): add undefined convert
2021-10-12 (1.3.0): bump version, add number convert
2021-04-01 (1.2.0): bump version, only use esbuild and add type declarion
2020-10-26 (1.1.0): rewrite to typescript and rollup
2018-05-31 (1.0.2): support array
2018-05-29 (1.0.1): reduce size (177KB -> 17KB)
2018-05-17 (1.0.0): publish init version

feature

  • parse your query for null / boolean / undefined
  • support nested query
  • support array
  • support numbered string convert

install

# use yarn
yarn add express-query-parser

# use npm
npm i express-query-parser

usage

const { queryParser } = require('express-query-parser')
const express = require('express')
const app = express()

app.use(
  queryParser({
    parseNull: true,
    parseUndefined: true,
    parseBoolean: true,
    parseNumber: true
  })
)

options

fielddesctypedefault
parseNullconvert all "null" to nullbooleantrue
parseUndefinedconvert all "undefined" to undefinedbooleantrue
parseBooleanconvert all "true" to true and "false" to falsebooleantrue
parseNumberconvert all numbered string to int and floatbooleantrue

Welcome any issues and PRs submit :D

Keywords

FAQs

Package last updated on 30 May 2022

Did you know?

Socket

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc