Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

koa-json-body

Package Overview
Dependencies
Maintainers
1
Versions
13
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

koa-json-body

koa middleware to parse json request bodies

  • 1.0.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
476
decreased by-44.46%
Maintainers
1
Weekly downloads
 
Created
Source

koa-json-body

Very simple koa middleware wrapper around co-body for parsing JSON request bodies. Largely inspired by koa-body.

This will not parse anythig but valid JSON request bodies. If there is a JSON error, the middleware will set ctx.request.body to {} and continue.

Installation

npm install koa-json-body --save

Options

Available via co-body:

  • limit - number or string representing the request size limit (default: 1mb)

Usage

On a every route:

var jsonBody = require('koa-json-body');

app.use(jsonBody({ limit: '10kb' }));

app.use(function *() {
  console.log(this.request.body);
});

On a per-route basis (using koa-router):

var jsonBody = require('koa-json-body')({ limit: '10kb' });

app.post('/users', jsonBody, function *() {
  console.log(this.request.body);
});

Keywords

FAQs

Package last updated on 23 Jul 2015

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