yeps-bodyparser
v1.1.1
Published
YEPS Parse request bodies
Downloads
24
Maintainers
Readme
YEPS body parser
Parse request bodies
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 byteslength
andexpected
- the expected length of the streamreceived
- the received bytesencoding
- the invalid encodingstatus
andstatusCode
- the corresponding status code for the errortype
- the error type
Example:
const options = {
limit: '1mb',
};
app.all([
bodyparser(options),
]);
See raw-body to get more details