FoalTS / foal

Full-featured Node.js framework, with no complexity. 🚀 Simple and easy to use, TypeScript-based and well-documented.
https://foalts.org/
MIT License
1.88k stars 137 forks source link

[Proposal] Give full control of express response object for user #1246

Open kingdun3284 opened 6 months ago

kingdun3284 commented 6 months ago

Although it is possible to add premiddleware to intercept the request before it is processed by foal's core. It is better to simply pass the raw express response object to Context as well. So developers can interact with the raw response object in advanced use case while hooks for checking incoming request can still be reusable when implementing features like SSE(server-sent event) or streaming. A simple check of the response type in sendResponse function to determine whether or not to execute the default behaviours would be fine.

@LoicPoullain What do you think? I can submit a PR for this feature.