koa 常用中间件

一、koa-static

 

  koa-static文档           https://www.npmjs.com/package/koa-static

const serve = require('koa-static');
const Koa = require('koa');
const app = new Koa();
 
// or use absolute paths
app.use(serve(__dirname + '/test/fixtures'));
 
app.listen(3000);
 

二、koa-bodyparser

  koa-bodyparser文档  https://www.npmjs.com/package/koa-bodyparser

var Koa = require('koa');
var bodyParser = require('koa-bodyparser');
 
var app = new Koa();
app.use(bodyParser());
 
app.use(async ctx => {
  ctx.body = ctx.request.body;
})

...

未完

...

你可能感兴趣的:(node)