Research
Security News
Quasar RAT Disguised as an npm Package for Detecting Vulnerabilities in Ethereum Smart Contracts
Socket researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
@medley/body-parser
Advanced tools
Essential body parsers for Medley.
This module provides the following parsers:
# npm
npm install @medley/body-parser --save
# yarn
yarn add @medley/body-parser
const bodyParser = require('@medley/body-parser');
The bodyParser
object exposes various factory functions that create a body-parsing
function that should be passed as the second argument to Medley's
app.addBodyParser()
method. All factory functions take an options
object for configuration.
The following describes each of the available factory functions.
bodyParser.json([options])
Parses request bodies as JSON using
JSON.parse()
.
const bodyParser = require('@medley/body-parser');
const medley = require('@medley/medley');
const app = medley();
app.addBodyParser('application/json', bodyParser.json());
1048576
(1 MiB)Specifies the maximum acceptable request body size.
bodyParser.json({limit: 100000})
bodyParser.text([options])
Parses request bodies into a string.
const bodyParser = require('@medley/body-parser');
const medley = require('@medley/medley');
const app = medley();
app.addBodyParser('text/plain', bodyParser.text());
// or
app.addBodyParser('text/*', bodyParser.text());
1048576
(1 MiB)Specifies the maximum acceptable request body size.
bodyParser.text({limit: 100000})
bodyParser.urlEncoded([options])
Parses URL-encoded request bodies into an object.
const bodyParser = require('@medley/body-parser');
const medley = require('@medley/medley');
const app = medley();
app.addBodyParser('application/x-www-form-urlencoded', bodyParser.urlEncoded());
1048576
(1 MiB)Specifies the maximum acceptable request body size.
bodyParser.urlEncoded({limit: 100000})
querystring.parse
Specifies the function that will parse the request body as a string into an object. This can be used
as a way to call querystring.parse()
with options.
const querystring = require('querystring');
function customParser(body) {
return querystring.parse(body, null, null, {maxKeys: 20});
}
bodyParser.urlEncoded({parser: customParser})
bodyParser.buffer([options])
Parses request bodies into a Buffer
.
const bodyParser = require('@medley/body-parser');
const medley = require('@medley/medley');
const app = medley();
app.addBodyParser('application/octet-stream', bodyParser.buffer());
// or to catch all requests
app.addBodyParser('*/*', bodyParser.buffer());
1048576
(1 MiB)Specifies the maximum acceptable request body size.
bodyParser.buffer({limit: 100000})
FAQs
Essential body parsers for Medley.
The npm package @medley/body-parser receives a total of 1 weekly downloads. As such, @medley/body-parser popularity was classified as not popular.
We found that @medley/body-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.
Research
Security News
Socket researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
Security News
Research
A supply chain attack on Rspack's npm packages injected cryptomining malware, potentially impacting thousands of developers.
Research
Security News
Socket researchers discovered a malware campaign on npm delivering the Skuld infostealer via typosquatted packages, exposing sensitive data.