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

Aggregate commonly-used middleware into a single, configurable module #57

Open
robertrossmann opened this issue Aug 15, 2018 · 1 comment

Comments

@robertrossmann
Copy link
Member

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)
@yunicz
Copy link

yunicz commented Nov 19, 2018

+1 sounds awesome

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

2 participants