-
Notifications
You must be signed in to change notification settings - Fork 0
/
server.js
51 lines (38 loc) · 854 Bytes
/
server.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
43
44
45
46
47
48
49
50
51
const Yoa = require('./application')
const app = new Yoa()
function delay() {
return new Promise((resolve, reject) => {
setTimeout(() =>{
resolve()
}, 2000)
})
}
app.use(async (ctx, next) => {
ctx.body = '1'
await next()
ctx.body += '2'
})
app.use(async (ctx, next) => {
ctx.body += '3'
await delay()
await next()
ctx.body += '4'
})
app.use(async (ctx, next) => {
ctx.body += '5'
})
// app.use((req, res) => {
// res.writeHead(200)
// res.end('hello yoa2')
// })
app.listen(9092, () => {
console.log('server start on port 9092')
})
// const http = require('http')
// const server = http.createServer((req, res) => {
// res.writeHead(200)
// res.end('hello yoa2')
// })
// server.listen(9092, () => {
// console.log('server start on port 9092')
// })