The `express-end` package provides a specific Express middleware designed to augment the default event handling on the `res` (response) object. Its primary function is to emit an `end` event whenever `res.end()` is called, crucially, even if the client connection has closed prematurely. This addresses a common limitation where the standard `finish` event on the `res` object might not reliably fire under such circumstances, preventing middleware from consistently determining when server-side processing for a request has fully concluded. This capability is useful for tasks like consistent post-request logging, resource cleanup, or metric collection. The package is currently at version `0.0.8` and has not been updated since 2016, indicating it is an abandoned project. Its core differentiator is providing a consistent signal for server-side request completion, regardless of client connection status, a problem that might be solved differently or directly in modern Express versions.
npm install express-endVerified import paths — ran on the pinned version, not inferred.
This example demonstrates how to integrate `express-end` middleware and listen for the custom `end` event alongside standard `close` and `finish` events on the response object, showing how `end` fires consistently.
Do not use this package in modern Node.js or Express applications. Seek modern alternatives or implement custom event emission if absolutely necessary.
Avoid monkey-patching where possible. If a similar functionality is needed, consider using libraries like `on-finished` which provide a more robust way to detect response completion, or implement a pattern that doesn't modify core Express objects directly.
Investigate if newer Express versions (e.g., 4.x and above) provide better event handling or if alternative packages like `on-finished` offer a more reliable solution for detecting when a response has fully completed its server-side processing.
Ensure `express` is installed (`npm install express`) and `app = express();` is correctly initialized before `app.use(endMw);`.
Thoroughly test `express-end` in isolation and with all other middleware. If conflicts arise, consider replacing `express-end` with a more modern and less intrusive solution like `on-finished`, which provides a callback when the response finishes or the client disconnects.
No dependency data recorded yet.