I'm building API routes using Next.js to send a image and text-file as response. In the Next.js documentation I can find middleware for use cases like redirection and cookies.
I have use-case where:
- I need to generate a unique-identifier for each request I'm receiving and add that in output of logs generated by Pino.
- Compress the Image and text-file I'm sending as response.
How can it be done using middlewares?