istanbul-middleware-ts is a TypeScript-first middleware designed for integrating Istanbul code coverage reporting into Node.js applications, primarily with Express.js. It provides HTTP endpoints to collect, reset, merge, report, and download code coverage data. The package is currently at version 1.1.4, indicating active maintenance with several recent minor releases, and offers complete TypeScript support with type definitions. Its release cadence appears to be driven by feature additions and bug fixes within the 1.x series. A key differentiator is its modern TypeScript implementation that is compatible with the API of the original `istanbul-middleware`, making it a drop-in replacement for users seeking enhanced type safety and up-to-date Node.js practices. It offers robust functionality for CI/CD pipelines and local development environments by enabling dynamic coverage data management, HTML report generation, and LCOV/ZIP package downloads, alongside features like differential coverage reporting against git targets.
npm install istanbul-middleware-tsVerified import paths — ran on the pinned version, not inferred.
This example sets up an Express.js server with the Istanbul middleware, making coverage reports and data available at the `/coverage` endpoint, and enabling GET requests to reset coverage.
Pass `{ resetOnGet: true }` to the `createHandler` options to enable `GET /reset` functionality.Install `diff-cover` (e.g., `pip install diff-cover`) and configure the `diffTarget` option in the `createHandler` options to a branch, commit, or tag.
Install Express.js and its type definitions: `npm install express @types/express`
Ensure `app` is an instance of `express()` before calling `app.use()`.
Use ES module import syntax: `import { createHandler } from 'istanbul-middleware-ts';`