Security News
GitHub Removes Malicious Pull Requests Targeting Open Source Repositories
GitHub removed 27 malicious pull requests attempting to inject harmful code across multiple open source repositories, in another round of low-effort attacks.
express/koa middleware to parse bson body.
For koa:
var Koa = require('koa');
var bodyBson = require('body-bson');
var app = new Koa();
app.use(bodyBson());
app.use(async ctx => {
// the parsed body will store in ctx.request.body
// if nothing was parsed, body will be undefined
// body may contain value of bson types
var body = ctx.request.body;
});
For express
var express = require('express')
var bodyBson = require('body-bson')
var app = express()
// parse application/bson
app.use(bodyBson.json())
app.use(function (req, res) {
// the parsed body will store in req.body
// if nothing was parsed, body will be undefined
// body may contain value of bson types
var body= req.body;
})
bodyBson
var bodyBson = require('body-bson')
The bodyBson function is a factory to create middleware.
app.use(bodyBson(option))
The middleware will populate the request.rawBody
property with the parsed body when the Content-Type request header matches the type option(default to
application/bson
), nothing would be modified if the Content-Type was not matched, or an error occurred.
bodyBson.bson
The default bson instance used by bodyBson. It's exported for convenience.
bson
Controls the bson instance to deserialize the body.
One method is required for the instance: bson.deserialize(buffer)
.
Defaults to instance created by bson@1.1.0
.
limit
Controls the maximum request body size. If this is a number, then the value specifies the number of bytes; if it is a
string, the value is passed to the bytes
library for parsing. Defaults to '10mb'.
type
Controls the matching Content-Type headers, can pass a string or an array of strings. Defaults to 'application/bson'
.
rawBody
Controls whether to generate request.rawBody
to represent raw buffer received. request.rawBody
will only be generated if request.rawBody
should be generated. Defaults to false
.
FAQs
express/koa middleware to parse bson body.
The npm package body-bson receives a total of 3 weekly downloads. As such, body-bson popularity was classified as not popular.
We found that body-bson 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
GitHub removed 27 malicious pull requests attempting to inject harmful code across multiple open source repositories, in another round of low-effort attacks.
Security News
RubyGems.org has added a new "maintainer" role that allows for publishing new versions of gems. This new permission type is aimed at improving security for gem owners and the service overall.
Security News
Node.js will be enforcing stricter semver-major PR policies a month before major releases to enhance stability and ensure reliable release candidates.