kurierjs / kurier

TypeScript framework to create JSON:API compliant APIs
https://kurier.readthedocs.io/en/latest/
MIT License
61 stars 9 forks source link

Support `transportLayerOptions` in `options` argument for middlewares #295

Closed joelalejandro closed 3 years ago

joelalejandro commented 3 years ago

transportLayerOptions is a breaking a bit the separation of concerns, introducing HTTP concepts in the scope of the Kurier application, which should be transport-layer agnostic. We should allow the middlewares by themselves to be configured.

Isn't this a middleware concern? It's kinda weird to be defined on Application.

For example, in Next.js it's defined inside api route file, a.k.a api/[...kurier].js https://nextjs.org/docs/api-routes/api-middlewares#custom-config

I imagine that for Koa it should be defined here:

const api = new Koa();

const config = {
  bodyParser: {
      sizeLimit: '1mb',
  },
};

api.use(jsonApiKoa(app, config));

api.listen(3000);

_Originally posted by @isBatak in https://github.com/kurierjs/kurier/pull/292#discussion_r657832321_