Skip to content
This repository has been archived by the owner on Jan 18, 2023. It is now read-only.

Explore support for Express and Koa middleware #16

Open
nahtnam opened this issue Jun 3, 2019 · 2 comments
Open

Explore support for Express and Koa middleware #16

nahtnam opened this issue Jun 3, 2019 · 2 comments
Assignees
Labels
enhancement New feature or request good first issue Good for newcomers
Milestone

Comments

@nahtnam
Copy link
Contributor

nahtnam commented Jun 3, 2019

Explore how Express and Koa middleware work to see if we can wrap them and support them in light.

@nahtnam nahtnam self-assigned this Jun 3, 2019
@nahtnam nahtnam added the enhancement New feature or request label Jun 3, 2019
@nahtnam nahtnam added this to the 2.0 milestone Jun 3, 2019
@nahtnam nahtnam added the good first issue Good for newcomers label Jun 3, 2019
@nahtnam nahtnam removed the good first issue Good for newcomers label Sep 26, 2019
@nahtnam
Copy link
Contributor Author

nahtnam commented Jun 3, 2020

We can use https://nextjs.org/docs/api-routes/api-middlewares#connectexpress-middleware-support for connect support (as seen in #79).

@nahtnam
Copy link
Contributor Author

nahtnam commented Jun 3, 2020

Turns out Koa also has the concept of "context" (I had no idea, been a long time since I used it) but this is what it looks like

app.use(async (ctx, next) => {
  const start = Date.now();
  await next();
  const ms = Date.now() - start;
  console.log(`${ctx.method} ${ctx.url} - ${ms}ms`);
});

The context contains https://koajs.com/#context but it seems a lot more complicated because its half middleware (doesn't look like a hoc), half plugin (but also allows you execute code after main handler).

Deferring this to later since Koa isn't as popular

@nahtnam nahtnam added the good first issue Good for newcomers label Jun 3, 2020
@nahtnam nahtnam modified the milestones: v2.0, v2.1 Jun 6, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement New feature or request good first issue Good for newcomers
Development

No branches or pull requests

1 participant