-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathexp.ts
38 lines (34 loc) · 775 Bytes
/
exp.ts
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
import * as Koa from 'koa'
import * as Router from 'koa-router'
import * as bodyparser from 'koa-bodyparser'
const app = new Koa()
const router = new Router()
router.post("/getname", async (ctx, next) => {
ctx.body = ctx.request.body
})
router.get("/",async (ctx, next) => {
ctx.body = "Hello, world"
try {
throw 'shit'
} catch (error) {
throw 'shit'
} finally {
return next()
}
})
app.use(bodyparser())
app.use(async (ctx, next) => {
try {
console.log("before", ctx.status)
await next()
console.log("after", ctx.status)
} catch (error) {
console.log("shit error")
}
})
app.use(router.routes())
app.use(ctx => {
console.log('reached')
// throw 'shit'
})
app.listen(4000)