Skip to content
This repository has been archived by the owner on Feb 17, 2019. It is now read-only.

Latest commit

 

History

History
48 lines (36 loc) · 1.16 KB

README.md

File metadata and controls

48 lines (36 loc) · 1.16 KB

alp-body-parser NPM version

body parser in alp framework

Dependency Status Dependency ci Status

Install

npm install --save alp-body-parser

Usage

import Koa from 'koa';
import config from 'alp-config';
import bodyParser from 'alp-body-parser';

const app = new Koa();
config(`${__dirname}/config`, { packageConfig })(app);
bodyParser(app);
export default {
    async form(ctx) {
        const body = await ctx.parseBody();
    },

    async json(ctx) {
        const body = await ctx.parseBodyJson();
    },

    async text(ctx) {
        const body = await ctx.parseBodyText();
    },
};