Skip to content

Latest commit

 

History

History
84 lines (51 loc) · 1.49 KB

Koa2.md

File metadata and controls

84 lines (51 loc) · 1.49 KB

Koa2

Koa2 支持 async,所以选择之。

安装

npm install koa@2

中间件

把1.0中间件转换成2.0的

json解析

$ npm install --save koa-bodyparser@next

Koa静态文件

Koa 路由

$ npm install --save koa-router@next

Koa middleware for serving a favicon.

$ npm install --save koa-favicon@next

压缩

$ npm install --save koa-compress@next

打印请求日志, 推荐

打印请求日志

$ npm install --save koa-logger@next

允许跨域访问

创建工程

生成 package.json

$ npm init