Koa-Bodyparser-TS:TypeScript 下的 Koabodyparser

Koa-Bodyparser-TS基于 Koa 中间件 Koa-Bodyparser 实现,支持解析 JSON、Form 和 Text 格式的请求体。

安装:

npm install koa-bodyparser-ts --save

使用方法:

1. 引入 Koa 和 Koa-Bodyparser-TS

2. 创建 Koa 应用

3. 使用 bodyParser 中间件

4. 在中间件函数中,解析后的请求体存储在 ctx.request.body 中

if (ctx.request.body) {

// 解析后的请求体

} else {

// 未解析到请求体

ctx.body = {};

}

zip
koa-bodyparser-ts-master.zip 预估大小:15个文件
folder
koa-bodyparser-ts-master 文件夹
file
.travis.yml 590B
file
package.json 2KB
file
tslint.json 744B
folder
tools 文件夹
file
build.js 469B
folder
test 文件夹
file
index.spec.ts 17KB
file
LICENSE 1KB
file
package-lock.json 276KB
folder
src 文件夹
file
index.ts 8KB
file
.npmignore 124B
file
tsconfig.json 402B
file
.gitignore 583B
file
CHANGELOG.md 4KB
file
README.md 3KB
folder
.vscode 文件夹
file
launch.json 827B
file
tasks.json 533B
zip 文件大小:63.27KB