|
|
|
|
|
by hombre_fatal
774 days ago
|
|
That still doesn't address the main difference between Express and Koa. In Express, the route handlers send the response directly so your middleware can only be "beforeware". In Koa, the route handlers update a response object that bubbles back up the stack before it's sent, so you can write both beforeware and afterware (so, real middleware). For example: app.use(async (ctx, next) => {
console.log('Request is going down', ctx.request.body)
await next()
console.log('Response is coming up', ctx.response.body)
})
|
|