1.0.0 • Published 4 months ago

@curveball/bodyparser v1.0.0

Weekly downloads
40
License
MIT
Repository
github
Last release
4 months ago

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.

1.0.0

4 months ago

0.6.1

1 year ago

0.6.0

1 year ago

0.5.0

2 years ago

0.4.14

3 years ago

0.4.13

3 years ago

0.4.12

3 years ago

0.4.10

3 years ago

0.4.11

3 years ago

0.4.9

3 years ago

0.4.8

3 years ago

0.4.7

3 years ago

0.4.6

4 years ago

0.4.5

4 years ago

0.4.4

4 years ago

0.4.3

5 years ago

0.4.2

5 years ago

0.4.1

5 years ago

0.4.0

6 years ago

0.3.0

6 years ago

0.2.2

6 years ago

0.2.1

6 years ago

0.2.0

6 years ago

0.1.0

6 years ago

0.0.2

6 years ago

0.0.1

6 years ago