-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.js
42 lines (38 loc) · 936 Bytes
/
app.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
30
31
32
33
34
35
36
37
38
39
40
41
42
const koa = require("./lib/koa-demo");
const Router = require('./middlewares/Router');
const router = new Router();
const app = new koa();
function sleep() {
return new Promise(resolve => {
setTimeout(() => {
resolve();
}, 2000);
});
}
app.use(require('./middlewares/static')());
app.use(require('./middlewares/logger'));
// 黑名单测试的127.0.0.1
// app.use(require('./middlewares/blacklist'));
// app.use(async (ctx, next) => {
// ctx.body = "1";
// await sleep();
// await next();
// ctx.body += "2";
// });
// app.use(async (ctx, next) => {
// ctx.body += "3";
// await next();
// ctx.body += "4";
// });
// app.use(async (ctx, next) => {
// ctx.body += "5";
// });
app.use(async (ctx, next) => {
ctx.body = 'docker ci test'
await next()
})
app.use(router.routes())
// 设置host参数,表名ipv4
app.listen(3200, '0.0.0.0', () => {
console.log(' server is running on '+ 3200)
});