Comment

Comment by always_good

http://koajs.com/

In Koa, handlers don't respond to the request. Instead, they update a representation of the response and return a promise. The response bubbles up to the top-level where the `res.send()` is done.

This way you have real middleware. You can post-process the response or do something else entirely after the downstream has run.

    const middleware = async (ctx, next) => {
      console.log('request going down')
      await next()
      console.log('request coming up')
    }
parent always_good 9 years ago

Discussion

Live from the official Hacker News API

A modern reader for Hacker News · SvelteKit + Skeleton