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

alpjs/alp-body-parser

Repository files navigation

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();
    },
};