New:Introducing Socket Scanning for VS Code Marketplace Extensions.Learn more →
Get Started

restify-async-json-body-parser

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

restify-async-json-body-parser

Asynchronously read JSON request body for restify.

latest
Source
npmnpm
Version
0.0.6
Version published
Weekly downloads
0
Maintainers
1
Weekly downloads
 
Created
Source

Restify async JSON body parser

Build Status NPM version

When using server.use(restify.bodyParser(), content is buffered being passed through to JSON.parse().

With very large JSON, this quickly becomes a bottleneck, hanging restify thread while parsing JSON.

This library parses application/json requests asynchronously to avoid blocking the main event loop. All other requests are left unchanged.

Request below a certain size are also sent to the default bodyParser for performance.

Usage

var restifyAsyncJsonBodyParser = require('restify-async-json-body-parser');

server.use(restifyAsyncJsonBodyParser());

Options

As for any restify middleware, you can pass options. Those options will get forwarded to the default bodyParser if used.

In addition to those options, you may use minLength to set a default size (in bytes) before switching to asynchronous. Default is 2500.

Keywords

restify

FAQs

Package last updated on 18 Feb 2014

Related posts