Skip to content

bodyparser 0.6.1

Install from the command line:
Learn more about npm packages
$ npm install @curveball/bodyparser@0.6.1
Install via package.json:
"@curveball/bodyparser": "0.6.1"

About this version

Curveball Body Parser

This package is a middleware for Curveball. It helps parsing JSON and Text request bodies.

When this middleware is added, it will automatically read all bodies from requests that have the following values as their Content-Type header:

  • application/json
  • application/*+json
  • application/x-www-form-urlencoded
  • text/*

It sets the result of this parsing process to the context.request.body property. In the case of text bodies, it will result in a string.

In the case of JSON bodies, it will be the result of JSON.parse on the body.

Installation

npm install @curveball/bodyparser

Getting started

import { Application } from '@curveball/core';
import bodyParser from '@curveball/bodyparser';

const app = new Application();
app.use(bodyParser());


app.use( ctx => {
  // Log request bodies
  console.log(ctx.request.body);
});

API

bodyParser

The default export for this package is the bodyParser function. When called, this function returns a middleware.

Details


Assets

  • bodyparser-0.6.1.tgz

Download activity

  • Total downloads 0
  • Last 30 days 0
  • Last week 0
  • Today 0

Recent versions

View all