next-api-compose icon indicating copy to clipboard operation
next-api-compose copied to clipboard

Feature Request: allow adding another middleware array optional param, to be executed at the end of the chain

Open Korayem opened this issue 3 years ago • 0 comments

Suggestion:

import { compose } from 'next-api-compose'

export default compose([preWithBar, preWithFoo], [postWithBar, postWithFoo], (request, response) => {
  const { foo, bar } = request
  response.status(200).json({ foo, bar })
})

Some of the reasons:

  • Logging
  • APM performance tracing
  • fetch.waitUntil() to trigger custom business logic (purge/refresh cache, CRUD events)
  • Analytics
  • HTTP Edge Cache storage of the response body

Korayem avatar Jun 05 '22 07:06 Korayem