Skip to content
This repository has been archived by the owner on Mar 17, 2022. It is now read-only.

A better way to plug in optional middlewares? #69

Open
JaneJeon opened this issue Aug 25, 2019 · 2 comments
Open

A better way to plug in optional middlewares? #69

JaneJeon opened this issue Aug 25, 2019 · 2 comments
Milestone

Comments

@JaneJeon
Copy link
Owner

JaneJeon commented Aug 25, 2019

It'd be ideal if we could just assume that the server is running in a vacuum where the only thing it needs to do is to handle req/res cycles.

But servers don't live in isolation - they are in dev/test/prod environments, they may or may not have reverse proxies (all of which have varying features at differing price points), deployed in bare machine/containers/by an orchestrator, etc.

And to account for the various environments and their features, we need a way to systematically plug in various middlewares with different conditions and orders.

Some of the middlewares that should be optional include:

  • https://github.com/AlbertoFdzM/express-list-endpoints (should be useful for dev)
  • URL rewriting, such as HTTP=>HTTPS, www=>non-www, trailing slash, etc (important if doing SSR and/or if the server is NOT behind a reverse proxy, e.g. Heroku)
  • rate-limiting! (a lot of API gateways/reverse proxies can handle this)
  • gzip compression (ditto)
  • logging, specifically request logging
  • circuit breaker
  • caching (oh boy)
  • metrics (newrelic/prometheus/various health check middlewares)
  • dashboards (e.g. for bull queue, express-status-monitor)

...and the list goes on.

Honestly, this shit makes me want to just swap to Fastify and use their plugin architecture (especially because of the order these middlewares need to be plugged in), but surely there must be a way to do this cleanly in express, right? (especially using the CENTRAL configuration system that I have already setup)

@JaneJeon JaneJeon added this to the MVP milestone Aug 25, 2019
@JaneJeon JaneJeon self-assigned this Aug 25, 2019
@JaneJeon
Copy link
Owner Author

JaneJeon commented Aug 25, 2019

Related: #68, #55, #54, #51, #42, #40, #39, #24, #23, #22, #16, #70

@JaneJeon
Copy link
Owner Author

Something like this: https://docs.nestjs.com/fundamentals/async-providers

JaneJeon added a commit that referenced this issue Sep 3, 2019
@JaneJeon JaneJeon removed their assignment Sep 11, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

1 participant