yeps-bodyparser

1.1.1 • Public • Published

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

Package Sidebar

Install

npm i yeps-bodyparser

Weekly Downloads

1

Version

1.1.1

License

MIT

Last publish

Collaborators

  • evheniy.bystrov