atlas.js
atlas.js copied to clipboard
Aggregate commonly-used middleware into a single, configurable module
Some middleware modules are used on every backend project because they provide key functionality to the HTTP layer, namely:
- koa-compress
- koa-bodyparser
- kcors
- koa-conditional-get & koa-etag
- koa-helmet
- koa-static
- koa-router
-
Authorization
header parser (JWT, mostly) - Error handler (catches errors thrown in middleware, logs them and sends a 5xx response back)
- Generic logger to log all incoming requests/responses
I think we could wrap most (if not all) of these modules into a single module so that consumers do not need to install and configure all of these manually.
Implementation requirements:
- Sensible defaults must be provided for all middleware
- Consumers must be able to disable or even replace any of them if they so choose, without affecting the other modules. Preferrably, the ordering of modules, especially when mixing these "built-in" middleware with user-defined middleware should be somehow configurable.
- Everything must be fully configurable
- Only what is generally considered a "standard" or "best practice" for REST APIs should be included (ie. do not enable clickjacking protection - we do not serve HTML so we do not need to enable this kind of protection)
+1 sounds awesome