{"_id":"express-response-middleware","_rev":"7-00b0dd2f86bb559a292d8e5741f1dbb6","name":"express-response-middleware","dist-tags":{"latest":"2.2.0"},"versions":{"1.0.0":{"name":"express-response-middleware","version":"1.0.0","keywords":["mung","middleware","transform","response","express"],"license":"MIT","_id":"express-response-middleware@1.0.0","maintainers":[{"name":"marklai1998","email":"marklai1998@pm.me"}],"homepage":"https://github.com/marklai1998/express-response-middleware#readme","bugs":{"url":"https://github.com/marklai1998/express-response-middleware/issues"},"dist":{"shasum":"54283546ad48031af1cccce31856984464dd8553","tarball":"https://registry.npmjs.org/express-response-middleware/-/express-response-middleware-1.0.0.tgz","fileCount":14,"integrity":"sha512-fbs3EJHxqkSawM1p/aTcmwgpYx8C4gSHrupuSoS4jfITFX9SJItgJBaXlrXTBq/9/Kxt/WDHrfWHc3KXMqlDaQ==","signatures":[{"sig":"MEUCIQCldyJeREA5rw5eoICi4Bf6sWafk75zbT27wnd8JkPW8QIgBPTg/Wm8GGMp/KQu7VJbb2dE/wrhkHuLmkLdkdl2DQU=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":32909},"main":"index.js","_from":"file:express-response-middleware-1.0.0.tgz","types":"index.d.ts","scripts":{"test":"mocha","lint:format":"prettier --check index.js index.d.ts package.json","lint:format:fix":"prettier --write index.js index.d.ts package.json"},"_npmUser":{"name":"marklai1998","email":"marklai1998@pm.me"},"_resolved":"/tmp/0281bb6a032bddbfa4145203569b745e/express-response-middleware-1.0.0.tgz","_integrity":"sha512-fbs3EJHxqkSawM1p/aTcmwgpYx8C4gSHrupuSoS4jfITFX9SJItgJBaXlrXTBq/9/Kxt/WDHrfWHc3KXMqlDaQ==","repository":{"url":"git+https://github.com/marklai1998/express-response-middleware.git","type":"git"},"_npmVersion":"10.9.2","description":"Transform an express response (or make until no good)","directories":{},"_nodeVersion":"22.14.0","dependencies":{},"_hasShrinkwrap":false,"devDependencies":{"mocha":"^5.2.0","should":"^13.2.3","express":"^4.16.3","bluebird":"^3.5.1","prettier":"3.5.2","supertest":"^3.1.0","@types/node":"22.9.1"},"_npmOperationalInternal":{"tmp":"tmp/express-response-middleware_1.0.0_1740965464766_0.5476537136767934","host":"s3://npm-registry-packages-npm-production"}},"2.0.0":{"name":"express-response-middleware","version":"2.0.0","keywords":["mung","middleware","transform","response","express"],"license":"MIT","_id":"express-response-middleware@2.0.0","maintainers":[{"name":"marklai1998","email":"marklai1998@pm.me"}],"homepage":"https://github.com/marklai1998/express-response-middleware#readme","bugs":{"url":"https://github.com/marklai1998/express-response-middleware/issues"},"dist":{"shasum":"64777f926f79aff018efc0483b113da3d66efcd2","tarball":"https://registry.npmjs.org/express-response-middleware/-/express-response-middleware-2.0.0.tgz","fileCount":35,"integrity":"sha512-SRlxLbrzPhsc2bwsogx0z73Tbp0T+Ca+mFUQZ1i/PMZ0FLpIrLowrNkBrkxo6Bgefik3sUIBP4Reb3bS7Pv8/g==","signatures":[{"sig":"MEQCIBtu6f1HH+OrDE3USd4pAwucZRpEnoEzkU7f7ORTfWTSAiAExAdcjEcym5JOnKVHybHrPMD7yacQoAmzs/pAQsIGDg==","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":107588},"main":"dist/cjs/index.cjs","_from":"file:express-response-middleware-2.0.0.tgz","types":"dist/esm/index.d.ts","module":"dist/esm/index.mjs","engines":{"node":">=18"},"scripts":{"test":"vitest run --coverage","build":"rollup -c","lint:format":"prettier --check src package.json","lint:format:fix":"prettier --write src package.json"},"_npmUser":{"name":"marklai1998","email":"marklai1998@pm.me"},"_resolved":"/tmp/dfbf2604a2a01dc31d5143b0a87f0a43/express-response-middleware-2.0.0.tgz","_integrity":"sha512-SRlxLbrzPhsc2bwsogx0z73Tbp0T+Ca+mFUQZ1i/PMZ0FLpIrLowrNkBrkxo6Bgefik3sUIBP4Reb3bS7Pv8/g==","repository":{"url":"git+https://github.com/marklai1998/express-response-middleware.git","type":"git"},"_npmVersion":"10.9.2","description":"Transform an express response","directories":{},"_nodeVersion":"22.14.0","_hasShrinkwrap":false,"devDependencies":{"rollup":"4.27.3","vitest":"3.0.7","prettier":"3.5.3","supertest":"7.0.0","typescript":"5.8.2","@types/node":"22.9.1","@types/express":"4.17.21","@types/supertest":"6.0.2","rollup-plugin-dts":"6.1.1","@vitest/coverage-v8":"3.0.7","rollup-plugin-esbuild":"6.2.1","rollup-plugin-peer-deps-external":"2.2.4"},"peerDependencies":{"express":"^4.0.0 || ^5.0.0"},"_npmOperationalInternal":{"tmp":"tmp/express-response-middleware_2.0.0_1742075409090_0.8505681954040549","host":"s3://npm-registry-packages-npm-production"}},"2.0.1":{"name":"express-response-middleware","version":"2.0.1","keywords":["mung","middleware","transform","response","express"],"license":"MIT","_id":"express-response-middleware@2.0.1","maintainers":[{"name":"marklai1998","email":"marklai1998@pm.me"}],"homepage":"https://github.com/marklai1998/express-response-middleware#readme","bugs":{"url":"https://github.com/marklai1998/express-response-middleware/issues"},"dist":{"shasum":"05b4284900bb791a678e8ad76194799f082eea42","tarball":"https://registry.npmjs.org/express-response-middleware/-/express-response-middleware-2.0.1.tgz","fileCount":36,"integrity":"sha512-tQNjn7e3Y3VCbK/oBRIGQU5fdPmZw0KUqxF+ZMnFAWV4kmR9DXXn6U1CoLtMclWoX2OfwKg87lIO8UJHqAtEIw==","signatures":[{"sig":"MEUCIQD62jSk24kVgs2QRcJfjzouAr3zbc0jE9AHycKKov3ZXgIgVXshkMkEfaLSPsn9zfwUK+CJoTlSkr8TEs+5/D3BlNE=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":107978},"main":"dist/cjs/index.cjs","_from":"file:express-response-middleware-2.0.1.tgz","types":"dist/esm/index.d.ts","module":"dist/esm/index.mjs","engines":{"node":">=18"},"scripts":{"test":"vitest run --coverage","build":"rollup -c","lint:format":"prettier --check src package.json","lint:format:fix":"prettier --write src package.json"},"_npmUser":{"name":"marklai1998","email":"marklai1998@pm.me"},"_resolved":"/tmp/710cd8f681dcd56564bbdc261e37d8d5/express-response-middleware-2.0.1.tgz","_integrity":"sha512-tQNjn7e3Y3VCbK/oBRIGQU5fdPmZw0KUqxF+ZMnFAWV4kmR9DXXn6U1CoLtMclWoX2OfwKg87lIO8UJHqAtEIw==","repository":{"url":"git+https://github.com/marklai1998/express-response-middleware.git","type":"git"},"_npmVersion":"10.9.2","description":"Transform an express response","directories":{},"_nodeVersion":"22.14.0","_hasShrinkwrap":false,"devDependencies":{"rollup":"4.27.3","vitest":"3.0.7","prettier":"3.5.3","supertest":"7.0.0","typescript":"5.8.2","@types/node":"22.9.1","@types/express":"4.17.21","@types/supertest":"6.0.2","rollup-plugin-dts":"6.1.1","@vitest/coverage-v8":"3.0.7","rollup-plugin-esbuild":"6.2.1","rollup-plugin-peer-deps-external":"2.2.4"},"peerDependencies":{"express":"^4.0.0 || ^5.0.0"},"_npmOperationalInternal":{"tmp":"tmp/express-response-middleware_2.0.1_1742075988963_0.9323501397386569","host":"s3://npm-registry-packages-npm-production"}},"2.1.0":{"name":"express-response-middleware","version":"2.1.0","keywords":["mung","middleware","transform","response","express"],"license":"MIT","_id":"express-response-middleware@2.1.0","maintainers":[{"name":"marklai1998","email":"marklai1998@pm.me"}],"homepage":"https://github.com/marklai1998/express-response-middleware#readme","bugs":{"url":"https://github.com/marklai1998/express-response-middleware/issues"},"dist":{"shasum":"7f059d16156af4e13f82d8e77e800461122ccaec","tarball":"https://registry.npmjs.org/express-response-middleware/-/express-response-middleware-2.1.0.tgz","fileCount":36,"integrity":"sha512-tiuRo94vrMlyKI81GkJhFgwCHMKz5lnhq5BZIxvA46mssWvxVz5mf55m08psA+EJbDKYcUSZlw/00UiJ6pAl1A==","signatures":[{"sig":"MEUCIGvBo5EKieAz/33ickkwtc1SnxEHrkSZNlHkLx9S87FnAiEApAKEDJjR4HLGuI6JV89kax+msOfiJfbqsDDqQifWSRU=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":108764},"main":"dist/cjs/index.cjs","type":"module","_from":"file:express-response-middleware-2.1.0.tgz","types":"dist/esm/index.d.ts","module":"dist/esm/index.mjs","engines":{"node":">=18"},"exports":{".":{"import":{"types":"./dist/esm/index.d.ts","default":"./dist/esm/index.mjs"},"require":{"types":"./dist/cjs/index.d.cts","default":"./dist/cjs/index.cjs"}}},"scripts":{"test":"vitest run --coverage","build":"rollup -c","lint:format":"prettier --check src package.json","lint:format:fix":"prettier --write src package.json"},"_npmUser":{"name":"marklai1998","email":"marklai1998@pm.me"},"_resolved":"/tmp/a2f4260fa2d431f7c779daf3657e7ba3/express-response-middleware-2.1.0.tgz","_integrity":"sha512-tiuRo94vrMlyKI81GkJhFgwCHMKz5lnhq5BZIxvA46mssWvxVz5mf55m08psA+EJbDKYcUSZlw/00UiJ6pAl1A==","repository":{"url":"git+https://github.com/marklai1998/express-response-middleware.git","type":"git"},"_npmVersion":"10.9.2","description":"Transform an express response","directories":{},"_nodeVersion":"22.14.0","typesVersions":{"*":{"*":["./dist/esm/index.d.ts"]}},"_hasShrinkwrap":false,"devDependencies":{"rollup":"4.35.0","vitest":"3.0.8","prettier":"3.5.3","supertest":"7.0.0","typescript":"5.8.2","@types/node":"22.13.10","@types/express":"5.0.0","@types/supertest":"6.0.2","rollup-plugin-dts":"6.1.1","@vitest/coverage-v8":"3.0.8","rollup-plugin-esbuild":"6.2.1","rollup-plugin-peer-deps-external":"2.2.4"},"peerDependencies":{"express":"^4.0.0 || ^5.0.0"},"_npmOperationalInternal":{"tmp":"tmp/express-response-middleware_2.1.0_1742078795641_0.2969702303264037","host":"s3://npm-registry-packages-npm-production"}},"2.1.2":{"name":"express-response-middleware","version":"2.1.2","keywords":["mung","middleware","transform","response","express"],"license":"MIT","_id":"express-response-middleware@2.1.2","maintainers":[{"name":"marklai1998","email":"marklai1998@pm.me"}],"homepage":"https://github.com/marklai1998/express-response-middleware#readme","bugs":{"url":"https://github.com/marklai1998/express-response-middleware/issues"},"dist":{"shasum":"f6de7e31ac2d5b5059614de37c7b1314b5ffe2a7","tarball":"https://registry.npmjs.org/express-response-middleware/-/express-response-middleware-2.1.2.tgz","fileCount":40,"integrity":"sha512-kbmE0V4CZsuUXZ+Vqdtj6bgbwltCYvecyp3DTMNXxQQ90wREoxP/4M1hhJXzeZe+3rKD2+BnDsFszDTWEYu07A==","signatures":[{"sig":"MEYCIQCgLw+H6fgWhuR84PcohIJxa3sWShWS/yElfnA3CXKcQQIhAP0oMgahB1QWCOJSv/s4xMwrAyEIBVvUeG+P41W/66dS","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":116150},"main":"dist/cjs/index.cjs","_from":"file:express-response-middleware-2.1.2.tgz","types":"dist/esm/index.d.ts","module":"dist/esm/index.mjs","engines":{"node":">=18"},"exports":{".":{"import":{"types":"./dist/esm/index.d.ts","default":"./dist/esm/index.mjs"},"require":{"types":"./dist/cjs/index.d.cts","default":"./dist/cjs/index.cjs"}}},"scripts":{"test":"vitest run --coverage","build":"rollup -c","pre-push":"tsc","pre-commit":"pnpm biome check --fix --staged --no-errors-on-unmatched"},"_npmUser":{"name":"marklai1998","email":"marklai1998@pm.me"},"_resolved":"/tmp/eb9dfca4dc3d3273321c383a46dfaa4e/express-response-middleware-2.1.2.tgz","_integrity":"sha512-kbmE0V4CZsuUXZ+Vqdtj6bgbwltCYvecyp3DTMNXxQQ90wREoxP/4M1hhJXzeZe+3rKD2+BnDsFszDTWEYu07A==","repository":{"url":"git+https://github.com/marklai1998/express-response-middleware.git","type":"git"},"_npmVersion":"10.9.2","description":"Transform an express response","directories":{},"_nodeVersion":"22.15.0","typesVersions":{"*":{"*":["./dist/esm/index.d.ts"]}},"_hasShrinkwrap":false,"devDependencies":{"husky":"9.1.7","rollup":"4.41.1","vitest":"3.1.4","supertest":"7.1.1","typescript":"5.8.3","@types/node":"22.15.21","@biomejs/biome":"1.9.4","@types/express":"5.0.2","@commitlint/cli":"19.8.1","@types/supertest":"6.0.3","rollup-plugin-dts":"6.2.1","@vitest/coverage-v8":"3.1.4","rollup-plugin-esbuild":"6.2.1","rollup-plugin-node-externals":"8.0.0","@commitlint/config-conventional":"19.8.1","rollup-plugin-peer-deps-external":"2.2.4"},"peerDependencies":{"express":"^4.0.0 || ^5.0.0"},"_npmOperationalInternal":{"tmp":"tmp/express-response-middleware_2.1.2_1748150512059_0.10947281892355987","host":"s3://npm-registry-packages-npm-production"}},"2.1.3":{"name":"express-response-middleware","version":"2.1.3","keywords":["mung","middleware","transform","response","express"],"license":"MIT","_id":"express-response-middleware@2.1.3","maintainers":[{"name":"marklai1998","email":"marklai1998@pm.me"}],"homepage":"https://github.com/marklai1998/express-response-middleware#readme","bugs":{"url":"https://github.com/marklai1998/express-response-middleware/issues"},"dist":{"shasum":"b9e035eac2dcfeb8974325d5f2e90992b05d8468","tarball":"https://registry.npmjs.org/express-response-middleware/-/express-response-middleware-2.1.3.tgz","fileCount":9,"integrity":"sha512-8+yXg2YgxHNKeoemW6EKwONcrlNgI1tGOKiP+u8sdMrZrdH1SoXupHzJc0AdPPU9EgQfnCLK38pY8ZnmB6jvWg==","signatures":[{"sig":"MEUCIFqk7fm6gcCdG0TgKAtGaCGeE5Z14tzorDg8NFlUcds8AiEA1RIsUlVcQA0C2sJDqbfqaBsrCy7r0L+GCVyyRaHEJUo=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":49995},"main":"dist/cjs/index.cjs","_from":"file:express-response-middleware-2.1.3.tgz","types":"dist/esm/index.d.ts","module":"dist/esm/index.mjs","engines":{"node":">=18"},"exports":{".":{"import":{"types":"./dist/esm/index.d.ts","default":"./dist/esm/index.mjs"},"require":{"types":"./dist/cjs/index.d.cts","default":"./dist/cjs/index.cjs"}}},"scripts":{"test":"vitest run --coverage","build":"rollup -c"},"_npmUser":{"name":"marklai1998","email":"marklai1998@pm.me"},"_resolved":"/tmp/b16c121e1ec30f5c8606dcd19f2d12ce/express-response-middleware-2.1.3.tgz","_integrity":"sha512-8+yXg2YgxHNKeoemW6EKwONcrlNgI1tGOKiP+u8sdMrZrdH1SoXupHzJc0AdPPU9EgQfnCLK38pY8ZnmB6jvWg==","repository":{"url":"git+https://github.com/marklai1998/express-response-middleware.git","type":"git"},"_npmVersion":"10.9.2","description":"Transform an express response","directories":{},"_nodeVersion":"22.15.0","typesVersions":{"*":{"*":["./dist/esm/index.d.ts"]}},"_hasShrinkwrap":false,"devDependencies":{"rollup":"4.41.1","vitest":"3.1.4","lefthook":"1.11.13","supertest":"7.1.1","typescript":"5.8.3","@types/node":"22.15.21","@biomejs/biome":"1.9.4","@types/express":"5.0.2","@commitlint/cli":"19.8.1","@types/supertest":"6.0.3","rollup-plugin-dts":"6.2.1","@vitest/coverage-v8":"3.1.4","rollup-plugin-esbuild":"6.2.1","rollup-plugin-node-externals":"8.0.0","@commitlint/config-conventional":"19.8.1","rollup-plugin-peer-deps-external":"2.2.4"},"peerDependencies":{"express":"^4.0.0 || ^5.0.0"},"_npmOperationalInternal":{"tmp":"tmp/express-response-middleware_2.1.3_1748220953392_0.007560032423608032","host":"s3://npm-registry-packages-npm-production"}},"2.2.0":{"name":"express-response-middleware","version":"2.2.0","description":"Transform an express response","main":"dist/index.js","module":"dist/index.mjs","types":"dist/index.d.mts","exports":{".":{"require":{"types":"./dist/index.d.ts","default":"./dist/index.js"},"import":{"types":"./dist/index.d.mts","default":"./dist/index.mjs"}}},"typesVersions":{"*":{"*":["./dist/index.d.mts"]}},"repository":{"type":"git","url":"git+https://github.com/marklai1998/express-response-middleware.git"},"keywords":["mung","middleware","transform","response","express"],"license":"MIT","bugs":{"url":"https://github.com/marklai1998/express-response-middleware/issues"},"homepage":"https://github.com/marklai1998/express-response-middleware#readme","devDependencies":{"@biomejs/biome":"2.3.3","@commitlint/cli":"20.1.0","@commitlint/config-conventional":"20.0.0","@types/express":"5.0.5","@types/node":"24.10.0","@types/supertest":"6.0.3","@vitest/coverage-v8":"4.0.6","lefthook":"2.0.2","supertest":"7.1.4","tsdown":"0.15.12","typescript":"5.9.3","vitest":"4.0.6"},"peerDependencies":{"express":"^4.0.0 || ^5.0.0"},"engines":{"node":">=18"},"scripts":{"build":"tsdown --format esm --format cjs","test":"vitest run --coverage"},"_id":"express-response-middleware@2.2.0","_integrity":"sha512-pLirRwlm+LaBnuhljldg026JLbPilptXIJb3fpJokV5M+oL05uLs13XUrmzsWmlJsB3LzRZxc8emjPq2G1+jlA==","_resolved":"/tmp/9cab299fa60c1ec23f34fd5e5b1da6ba/express-response-middleware-2.2.0.tgz","_from":"file:express-response-middleware-2.2.0.tgz","_nodeVersion":"24.11.0","_npmVersion":"11.6.1","dist":{"integrity":"sha512-pLirRwlm+LaBnuhljldg026JLbPilptXIJb3fpJokV5M+oL05uLs13XUrmzsWmlJsB3LzRZxc8emjPq2G1+jlA==","shasum":"ceb7b4c64f4132138f94d8328a62da9d3afd7c84","tarball":"https://registry.npmjs.org/express-response-middleware/-/express-response-middleware-2.2.0.tgz","fileCount":7,"unpackedSize":21342,"attestations":{"url":"https://registry.npmjs.org/-/npm/v1/attestations/express-response-middleware@2.2.0","provenance":{"predicateType":"https://slsa.dev/provenance/v1"}},"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEUCIAQ0ezlk7dLquqIBVPxFtELSwkbMXrCPNex/Zwmo60d4AiEAindG2idbOX0p8XL/jYCMNTRYVVR2sfNcG3JU12UPzZM="}]},"_npmUser":{"name":"GitHub Actions","email":"npm-oidc-no-reply@github.com","trustedPublisher":{"id":"github","oidcConfigId":"oidc:2e415793-2f38-44e0-8f67-147eb0dbc47b"}},"directories":{},"maintainers":[{"name":"marklai1998","email":"marklai1998@pm.me"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/express-response-middleware_2.2.0_1762207478905_0.9092858342627372"},"_hasShrinkwrap":false}},"time":{"created":"2025-03-03T01:31:04.765Z","modified":"2025-11-03T22:04:39.531Z","1.0.0":"2025-03-03T01:31:04.918Z","2.0.0":"2025-03-15T21:50:09.259Z","2.0.1":"2025-03-15T21:59:49.166Z","2.1.0":"2025-03-15T22:46:35.833Z","2.1.2":"2025-05-25T05:21:52.270Z","2.1.3":"2025-05-26T00:55:53.577Z","2.2.0":"2025-11-03T22:04:39.131Z"},"bugs":{"url":"https://github.com/marklai1998/express-response-middleware/issues"},"license":"MIT","homepage":"https://github.com/marklai1998/express-response-middleware#readme","keywords":["mung","middleware","transform","response","express"],"repository":{"type":"git","url":"git+https://github.com/marklai1998/express-response-middleware.git"},"description":"Transform an express response","maintainers":[{"name":"marklai1998","email":"marklai1998@pm.me"}],"readme":"# Express Response Middleware\n\n> [!NOTE]  \n> Come from express-mung? Checkout the [Migration Guide](docs/MIGRATE_FROM_MUNG.md)\n\n<div align=\"center\">\n\nMiddleware for express responses. Fork of [express-mung](https://www.npmjs.com/package/express-mung)\n\nThis package allows synchronous and asynchronous transformation of an express response. This is a similar concept to the express middleware for a request but for a response. Note that the middleware is executed in LIFO order. It is implemented by monkey patching (hooking) the `res.end`, `res.json`, or `res.write` methods.\n\n![NPM](https://img.shields.io/npm/v/express-response-middleware) ![GitHub CI](https://github.com/marklai1998/express-response-middleware/actions/workflows/runTest.yml/badge.svg) [![Conventional Commits](https://img.shields.io/badge/Conventional%20Commits-1.0.0-yellow.svg)](https://conventionalcommits.org) [![npm type definitions](https://img.shields.io/npm/types/typescript.svg)](https://www.typescriptlang.org/)\n\n[Installation](#-installation) | [Quick Start](#-quick-start) | [API](#-api) | [Contributing](#-contributing)\n\n</div>\n\n## 📦 Installation\n\n### NPM\n\n```bash\nnpm i express-response-middleware\n```\n\n### Yarn\n\n```\nyarn add express-response-middleware\n```\n\n### PNPM\n\n```\npnpm i express-response-middleware\n```\n\n## 🚀 Quick Start\n\nSample middleware (redact.js) to remove classified information.\n\n```javascript\nimport { jsonMiddleware } from 'express-response-middleware'\n\n/* Remove any classified information from the response. */\nexport const hideSecretMiddleware = jsonMiddleware((body, req, res) => {\n    if (body.secret) body.secret = '****'\n    // ...\n    return body\n})\n```\n\nthen add to your `app.js` file (before the route handling middleware)\n\n```javascript\napp.use(hideSecretMiddleware)\n```\n\n## 💻 API\n\n- [Json Middleware](#jsonmiddleware)\n- [Jsonp Middleware](#jsonpmiddleware)\n- [Send Middleware](#sendmiddleware)\n- [End Middleware](#endMiddleware)\n- [Write Middleware](#endMiddleware)\n- Legacy docs\n  - [V1](docs/V1_README.md)\n\n### `jsonMiddleware`\n\nIntercept `res.json`, allow transform the JSON body of the response.\n\n```ts\nimport { jsonMiddleware } from 'express-response-middleware'\n\nconst myMiddleware = jsonMiddleware((json, req, res) => {\n    // your code here\n    return json\n})\n```\n\n### `jsonpMiddleware`\n\nIntercept `res.jsonp`, allow transform the JSON body of the response.\n\n```ts\nimport { jsonpMiddleware } from 'express-response-middleware'\n\nconst myMiddleware = jsonpMiddleware((json, req, res) => {\n    // your code here\n    return json\n})\n```\n\n### `sendMiddleware`\n\nIntercept `res.send`, allow transform the body of the response.\n\n```ts\nimport { sendMiddleware } from 'express-response-middleware'\n\nconst myMiddleware = sendMiddleware((payload, req, res) => {\n    // your code here\n    return payload\n})\n```\n\n### `endMiddleware`\n\nIntercept `end.json`, allow transform the HTTP headers of the response.\n\n```ts\nimport { endMiddleware } from 'express-response-middleware'\n\nconst myMiddleware = endMiddleware((req, res) => {\n    // your code here\n})\n```\n\n> [!CAUTION]\n> Sending a response while in `endMiddleware*` is **undefined behaviour** and will most likely result in an error\n\n### `writeMiddleware`\n\nIntercept `end.write`, allow transform buffer.\n\n```ts\nimport { writeMiddleware } from 'express-response-middleware'\n\nconst myMiddleware = writeMiddleware((chunk, encoding, req, res) => {\n    // your code here\n    return chunk\n})\n```\n\n> [!CAUTION]\n> Promise callback support is limited, it doesn't resolve multiple write call yet [Code](src/writeMiddleware.ts)\n\n- When `writeMiddleware` detects that a response has completed (i.e. if `res.end` has been called), it will abort.\n- Calling `res.json` or `res.send` from `writeMiddleware` can lead to unexpected behavior since they end the response internally.\n- The returned value of `res.write` will be inaccurate when using `writeMiddleware`, beware if you rely on it\n- `res.end` after `res.write` would not trigger endMiddleware, as header already sent\n\n## Exception handling\n\n`responseMiddleware` catches any exception (synchronous, asynchronous or Promise reject) and sends an HTTP 500 response with the exception message. You should handle your own error if you want different behavior\n\n## 🤝 Contributing\n\n### TODO\n\nCurrent state project is up to modern standard and support all of the `express-mung` use case, here is the list that I think can improve on. \n\n- [ ] Support multiple write call with `writeMiddleware` + async handler\n\n### Development\n\n#### Local Development\n\n```bash\npnpm i\npnpm test\n```\n\n#### Build\n\n```bash\npnpm build\n```\n\n### Release\n\nThis repo uses [Release Please](https://github.com/google-github-actions/release-please-action) to release.\n\n#### To release a new version\n\n1. Merge your changes into the `main` branch.\n2. An automated GitHub Action will run, triggering the creation of a Release PR.\n3. Merge the release PR.\n4. Wait for the second GitHub Action to run automatically.\n5. Congratulations, you're all set!\n","readmeFilename":"README.md"}