JaneJeon / express-objection-starter

an opinionated, production-ready, isomorphic express/knex/objection starter with centralized configuration
https://objection.netlify.com
MIT License
19 stars 2 forks source link

A better way to plug in optional middlewares? #69

Open JaneJeon opened 5 years ago

JaneJeon commented 5 years ago

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:

...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 commented 5 years ago

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

JaneJeon commented 5 years ago

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