koa
文档:Koa (koajs)
常用中间件
路由
bashnpm install @koa/router npm install @types/koa__router -D
1
2body
bashnpm i koa-body
1cors
bashnpm i @koa/cors npm i @types/koa__cors
1
2
安装
bash
npm install koa
npm install @types/koa -D
1
2
2
基本使用
typescript
import Koa from 'koa'
const app = new Koa()
app.use(async (context:Koa.Context) => {
context.body = 'Hi'
})
app.listen(3000, '0.0.0.0', () => {
console.log('服务器启动成功')
})
1
2
3
4
5
6
7
8
9
10
11
2
3
4
5
6
7
8
9
10
11