Security News
The Push to Ban Ransom Payments Is Gaining Momentum
Ransomware costs victims an estimated $30 billion per year and has gotten so out of control that global support for banning payments is gaining momentum.
koa-qs
Advanced tools
Readme
By default, Koa uses the native querystring
module which does not provide nesting support.
This patches a koa app with nesting support via the qs support,
which is also used by Connect and Express.
Simply wrap a koa app with this module:
// Koa 1.x.x
const koa = require('koa')
const app = koa()
require('koa-qs')(app)
// Koa 2.x.x
const Koa = require('koa')
const app = new Koa()
require('koa-qs')(app)
There're three parse mode.
extended
modeThe default mode, use [qs] module.
require('koa-qs')(app, 'extended')
simple
modeUse querystring
module, same as koa does by default.
If you want to use this mode, don't use this module.
strict
modeThis mode make this.query.foo
return strict array
.
require('koa-qs')(app, 'strict')
A normal request GET /foo?p=a&q=foo&q=bar
.
console.log('%j', this.query);
{
"p": "a",
"q": ["foo", "bar"]
}
console.log('%j', this.query);
{
"p": ["a"],
"q": ["foo", "bar"]
}
first
modeThis mode make this.query.foo
return strict string
. Disable multi values.
If querystring contains multi same name params, return the first item.
require('koa-qs')(app, 'first')
In 95% use cases, application only want string
query params.
This patch can avoid some stupid TypeError
and some security issues like MongoDB inject
when the developers forget handling query params type check.
A normal request GET /foo?p=a,b&p=b,c
.
console.log('%j', this.query.p);
["a,b", "b,c"]
console.log('%j', this.query.p);
"a,b"
FAQs
qs for koa
We found that koa-qs demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 10 open source maintainers 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
Ransomware costs victims an estimated $30 billion per year and has gotten so out of control that global support for banning payments is gaining momentum.
Application Security
New SEC disclosure rules aim to enforce timely cyber incident reporting, but fear of job loss and inadequate resources lead to significant underreporting.
Security News
The Python Software Foundation has secured a 5-year sponsorship from Fastly that supports PSF's activities and events, most notably the security and reliability of the Python Package Index (PyPI).