yeps-bodyparser
JavaScript
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
tests
.editorconfig
.eslintrc
.gitignore
.istanbul.yml
.travis.yml
LICENSE
README.md
appveyor.yml
index.js
package.json

README.md

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