-
Notifications
You must be signed in to change notification settings - Fork 1
/
test.js
29 lines (23 loc) · 612 Bytes
/
test.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
const SMKoa = require('./super-mini-koa');
const Koa = require('koa');
const app = new SMKoa(); // or new Koa();
app.use(async (ctx, next) => {
console.log('middleware1 req');
await next();
console.log('middleware1 res');
});
app.use(async (ctx, next) => {
console.log('middleware2 req');
await next();
console.log('middleware2 res');
});
app.use(async (ctx, next) => {
console.log('middleware3 req');
await next();
});
app.use(async ctx => {
console.log('set body hello world');
ctx.res.body = ctx.body = 'hello world';
});
app.listen(8088);
console.log('server listen on 8088...');