1.1.1 • Published 7 years ago

yeps-bodyparser v1.1.1

Weekly downloads
6
License
MIT
Repository
github
Last release
7 years ago

YEPS body parser

Parse request bodies

NPM

npm version Build Status Coverage Status Linux Build Windows Build

Dependency Status devDependency Status NSP Status

License GitHub stars GitHub forks GitHub issues Twitter

How to install

npm i -S yeps-bodyparser

How to use

const App = require('yeps');

const error = require('yeps-error');
const logger = require('yeps-logger');
const server = require('yeps-server');

const bodyparser = require('yeps-bodyparser');

const app = new App();

const options = {};

app.all([
    error(),
    logger(),
    bodyparser(options),
]);

app.then(async (ctx) => {
    ctx.res.statusCode = 200;
    ctx.res.end(JSON.stringify(ctx.request.body));
});

server.createHttpServer(app);

Options

  • limit - the limit in bytes
  • length and expected - the expected length of the stream
  • received - the received bytes
  • encoding - the invalid encoding
  • status and statusCode - the corresponding status code for the error
  • type - the error type

Example:

const options = {
    limit: '1mb',
};

app.all([
    bodyparser(options),
]);

See raw-body to get more details

YEPS documentation

1.1.1

7 years ago

1.1.0

7 years ago

1.0.1

7 years ago

1.0.0

7 years ago

0.0.1

7 years ago