安装插件
安装 body 解析插件
npm install koa-better-body -Snpm i @types/koa-bodyparser -Dimport * as Koa from 'koa';
import * as formidable from 'formidable';
declare module "koa"{
interface Request {
body: any,
files: any,
fields: any
}
}
declare function bodyParser(opts? : {
fields?: boolean | string,
files?: boolean | string,
multipart?: boolean,
textLimit?: string,
formLimit?: string,
urlencodedLimit?: string,
jsonLimit?: string,
bufferLimit?: string,
jsonStrict?: boolean,
detectJSON?: () => any,
strict?: boolean,
onerror?: () => any,
extendTypes?: Object,
IncomingForm?: formidable.IncomingForm,
handler?: GeneratorFunction,
querystring?: Object,
qs?: Object,
delimiter?: string,
sep?: string,
buffer?: boolean
}): Koa.Middleware;
declare namespace bodyParser {}
export = bodyParser;安装路由插件
Convert
Last updated