http-metrics-middleware icon indicating copy to clipboard operation
http-metrics-middleware copied to clipboard

Better support for Koa and other non-express frameworks...

Open hairyhenderson opened this issue 6 years ago • 2 comments

I'm personally not very familiar with frameworks other than express, but a number of colleagues have started to use Koa, and this module's dependency on the express module, and a few other factors, have prevented them from adopting this module directly.

I'd like to gather feedback on what the particular issues are, for example - apparently koa-connect may cause "issues", though it's unclear what those issues might be.

Ideally this module's dependency on express (or any other framework) should be optional.

I'm open to any comments that people have on this 🙂...

hairyhenderson avatar Mar 16 '18 19:03 hairyhenderson

The express dependency right now is probably pretty easily removed, but it will likely come as a cost of people having to implement the middleware themselves. I don't think that is a problem though, it's a pretty common pattern that middelwares only deliver the middleware, and people bind it to their routes themselves.

Exposing this library as a "plain" middleware should likely work in most express-like scenarios (express, koa), but also exposing the metrics logic on its own as hooks would support the majority of other libraries (although, I think supporting express and koa likely covers a huge majority of use cases).

peol avatar Mar 16 '18 19:03 peol

I think #17 fixes any functional issues with using this middleware with Koa, though I think it may still be possible to remove the express dependency, or at least make it optional.

hairyhenderson avatar Jun 01 '18 11:06 hairyhenderson