{"_id":"http2-express","_rev":"5-e0aef9e7e3338bb2863bf6d98ead3610","name":"http2-express","dist-tags":{"latest":"1.1.2"},"versions":{"1.0.0":{"name":"http2-express","version":"1.0.0","keywords":["express","http2","https","push","support","compatibility","api","server"],"author":{"name":"Mark Jovis"},"license":"MIT","_id":"http2-express@1.0.0","maintainers":[{"name":"markjovis","email":"mark.jovis@hotmail.com"}],"contributors":[{"name":"Mark Jovis","email":"mark.jovis@hotmail.com"}],"homepage":"https://github.com/markjovis/http2-express#readme","bugs":{"url":"https://github.com/markjovis/http2-express/issues"},"dist":{"shasum":"8f5be2c199ca34e9e7565ea2008be1d2a7dbc8c0","tarball":"https://registry.npmjs.org/http2-express/-/http2-express-1.0.0.tgz","fileCount":20,"integrity":"sha512-4sFhcpICPKonFHyBMGD9jT+2/Jg+J8qZTyuOHZPzHe7lbnPPOcJwlYqKfMukfvdH+F+0q6B9zifsHkHEGUJ7cg==","signatures":[{"sig":"MEQCIBlEqGDspakhpMvTueDa75yBad+Q0FrLjsF1IB0SVJzFAiB0P6vC+nSkoXHYzq4HqY3/PDETsvs6PK/wifky3k1MkA==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":233244},"main":"dist/index.js","module":"dist/index.js","engines":{"node":">= 20.0.0"},"gitHead":"ee5cb8439afdb5192646a45d23460e8eedf75cda","scripts":{"test":"echo \"Error: no test specified\" && exit 1","build":"babel src -d dist","prepublishOnly":"npm run build","createTypeFiles":"npx -p typescript tsc src/*.js --declaration --allowJs --emitDeclarationOnly --outDir types"},"_npmUser":{"name":"markjovis","email":"mark.jovis@hotmail.com"},"repository":{"url":"git+https://github.com/markjovis/http2-express.git","type":"git"},"_npmVersion":"10.8.3","description":"HTTP/2 support for Express","directories":{},"_nodeVersion":"22.9.0","_hasShrinkwrap":false,"devDependencies":{"eslint":"^8.57.0","@babel/cli":"^7.23.9","@babel/preset-env":"^7.23.9","@babel/eslint-parser":"^7.23.10","eslint-plugin-import":"^2.29.1","eslint-config-airbnb-base":"^15.0.0"},"_npmOperationalInternal":{"tmp":"tmp/http2-express_1.0.0_1730681645444_0.9006923046000719","host":"s3://npm-registry-packages"}},"1.0.1":{"name":"http2-express","version":"1.0.1","keywords":["express","http2","https","push","support","compatibility","api","server"],"author":{"name":"Mark Jovis"},"license":"MIT","_id":"http2-express@1.0.1","maintainers":[{"name":"markjovis","email":"mark.jovis@hotmail.com"}],"contributors":[{"name":"Mark Jovis","email":"mark.jovis@hotmail.com"}],"homepage":"https://github.com/markjovis/http2-express#readme","bugs":{"url":"https://github.com/markjovis/http2-express/issues"},"dist":{"shasum":"5865adc1637220eec55a6dafa2c8d495607751e8","tarball":"https://registry.npmjs.org/http2-express/-/http2-express-1.0.1.tgz","fileCount":17,"integrity":"sha512-3NP5595eHFkZOBD4RXCNDrTQvuxKfcr3Q62RrHlywNc0vw/PR2HKxtF4JqFhXWVJsxb9pTf/1hZ8iLaJrWdUmQ==","signatures":[{"sig":"MEUCIQD47lk98eV9QtjAsNRriYDYTkm9X0ufqmQ778Je0g+kbAIgUHevUc3HqGaZHHNx8WnBoyHOzq+6w5oib1tCwj32iMk=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":19248},"main":"dist/index.js","module":"dist/index.js","engines":{"node":">= 20.0.0"},"gitHead":"42d7b958f73ab7be1038023090c2f6af011c3a48","scripts":{"test":"echo \"Error: no test specified\" && exit 1","build":"babel src -d dist","prepublishOnly":"npm run build","createTypeFiles":"npx -p typescript tsc src/*.js --declaration --allowJs --emitDeclarationOnly --outDir types"},"_npmUser":{"name":"markjovis","email":"mark.jovis@hotmail.com"},"repository":{"url":"git+https://github.com/markjovis/http2-express.git","type":"git"},"_npmVersion":"10.9.2","description":"HTTP/2 support for Express","directories":{},"_nodeVersion":"22.9.0","_hasShrinkwrap":false,"devDependencies":{"eslint":"^8.57.0","@babel/cli":"^7.23.9","@babel/preset-env":"^7.23.9","@babel/eslint-parser":"^7.23.10","eslint-plugin-import":"^2.29.1","eslint-config-airbnb-base":"^15.0.0"},"_npmOperationalInternal":{"tmp":"tmp/http2-express_1.0.1_1734582316870_0.23928409821485475","host":"s3://npm-registry-packages-npm-production"}},"1.1.0":{"name":"http2-express","version":"1.1.0","keywords":["express","http2","https","push","support","compatibility","api","server"],"author":{"name":"Mark Jovis"},"license":"MIT","_id":"http2-express@1.1.0","maintainers":[{"name":"markjovis","email":"mark.jovis@hotmail.com"}],"contributors":[{"name":"Mark Jovis","email":"mark.jovis@hotmail.com"}],"homepage":"https://github.com/markjovis/http2-express#readme","bugs":{"url":"https://github.com/markjovis/http2-express/issues"},"dist":{"shasum":"7e7de1ceb06b70a92adb3736df9041a0da6b7f74","tarball":"https://registry.npmjs.org/http2-express/-/http2-express-1.1.0.tgz","fileCount":17,"integrity":"sha512-rEKh5J8KBh76SZ9ejs4q2SQV5X5DA7pMamuGod2ifPLCRcgm8Ru1awbyPPr56JzzMpUY+MKc2NlUxsGpaaqO4Q==","signatures":[{"sig":"MEUCIGqjsbb0dnyOBJgnrt64gwD7M6pjRDRogbkIrpdGvNHRAiEA3uWiRjHw58XrfYxWYC352fgC0qcrS9Mw++NoJ0Op3io=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":21639},"main":"dist/index.js","module":"dist/index.js","engines":{"node":">= 20.0.0"},"gitHead":"d095d3eb6fdb37c5c2a70394822ffacbe93c6e8d","scripts":{"test":"echo \"Error: no test specified\" && exit 1","build":"babel src -d dist","prepublishOnly":"npm run build","createTypeFiles":"npx -p typescript tsc src/*.js --declaration --allowJs --emitDeclarationOnly --outDir types"},"_npmUser":{"name":"markjovis","email":"mark.jovis@hotmail.com"},"repository":{"url":"git+https://github.com/markjovis/http2-express.git","type":"git"},"_npmVersion":"11.5.2","description":"HTTP/2 support for Express","directories":{},"_nodeVersion":"24.6.0","_hasShrinkwrap":false,"devDependencies":{"eslint":"^8.57.0","@babel/cli":"^7.23.9","@babel/preset-env":"^7.23.9","@babel/eslint-parser":"^7.23.10","eslint-plugin-import":"^2.29.1","eslint-config-airbnb-base":"^15.0.0"},"_npmOperationalInternal":{"tmp":"tmp/http2-express_1.1.0_1758153700980_0.7931760086995017","host":"s3://npm-registry-packages-npm-production"}},"1.1.1":{"name":"http2-express","version":"1.1.1","keywords":["express","http2","https","push","support","compatibility","api","server"],"author":{"name":"Mark Jovis"},"license":"MIT","_id":"http2-express@1.1.1","maintainers":[{"name":"markjovis","email":"mark.jovis@hotmail.com"}],"contributors":[{"name":"grainrigi"}],"homepage":"https://github.com/markjovis/http2-express#readme","bugs":{"url":"https://github.com/markjovis/http2-express/issues"},"dist":{"shasum":"769a0b25f47d3358687c47a124e75ec33329594a","tarball":"https://registry.npmjs.org/http2-express/-/http2-express-1.1.1.tgz","fileCount":9,"integrity":"sha512-iROf3EIQdJZLNk+/LTkENZp1WB8B+IrYT+z/TPP3/RyGk6w9P9QZNDvs/lo5zAOozNuNYdHewIyWVXXAkBGQ7g==","signatures":[{"sig":"MEUCIQCv+M6kITVJsoJQKfMge1uCAD1DTc7XxqGpBljSJMQM/gIgPPp0VRefNJhjJLbptIrzbFCzvVJ22OPo6PaxYMc7OaQ=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":14783},"main":"src/index.js","type":"commonjs","engines":{"node":">= 20.0.0"},"gitHead":"8f9db944c5b7a418b8371c44ab2f00af1da5d74c","scripts":{"createTypeFiles":"npx -p typescript tsc src/*.js --declaration --allowJs --emitDeclarationOnly --outDir types"},"_npmUser":{"name":"markjovis","email":"mark.jovis@hotmail.com"},"repository":{"url":"git+https://github.com/markjovis/http2-express.git","type":"git"},"_npmVersion":"11.12.1","description":"HTTP/2 support for Express","directories":{},"sideEffects":false,"_nodeVersion":"25.2.1","_hasShrinkwrap":false,"devDependencies":{"eslint":"^10.5.0","globals":"^17.6.0","@eslint/js":"^10.0.1"},"peerDependencies":{"express":">=4.0.0"},"_npmOperationalInternal":{"tmp":"tmp/http2-express_1.1.1_1781759871276_0.25103750139546155","host":"s3://npm-registry-packages-npm-production"}},"1.1.2":{"_id":"http2-express@1.1.2","bugs":{"url":"https://github.com/markjovis/http2-express/issues"},"dist":{"shasum":"4212764e77b4a392a78e1c94c650ca9c6085bbc2","tarball":"https://registry.npmjs.org/http2-express/-/http2-express-1.1.2.tgz","fileCount":10,"integrity":"sha512-0ns/zoiPtH5z5OVbDs71CjxtnvsV5guhJG/c6qAlH5euCJFD+6DhAIj8JdDp8lr3gi3AdVVBy9hlAZq69eD5Lg==","signatures":[{"sig":"MEUCIQD+64NmFNHA8EQ2h2bbPFaV87+WuGH4SozaX1+UzP+vzgIgHwW0xfnRf1/ON3g6wFkibh22F/bLn662rJjet3x0TDY=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"},{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEYCIQCcMwtzCd71LvyL9c7KcuSDok0CdJdWJmB1tAhnJcH7IAIhANJ96KTfEU/K1fD8FQi4C1bydWxSSQu2x3293MA8jCIv"}],"unpackedSize":23544},"main":"src/index.js","name":"http2-express","type":"commonjs","types":"src/index.d.ts","author":{"name":"Mark Jovis"},"engines":{"node":">= 20.0.0"},"gitHead":"c9acb0305ab5cf9d4e505b63068b6515e95b892b","license":"MIT","scripts":{"typecheck":"tsc -p tsconfig.json"},"version":"1.1.2","_npmUser":{"name":"markjovis","email":"mark.jovis@hotmail.com"},"homepage":"https://github.com/markjovis/http2-express#readme","keywords":["express","http2","https","push","support","compatibility","api","server"],"repository":{"url":"git+https://github.com/markjovis/http2-express.git","type":"git"},"_npmVersion":"11.19.1","description":"HTTP/2 support for Express","directories":{},"maintainers":[{"name":"markjovis","email":"mark.jovis@hotmail.com"}],"sideEffects":false,"_nodeVersion":"26.10.0","contributors":[{"name":"grainrigi"}],"_hasShrinkwrap":false,"devDependencies":{"eslint":"^10.5.0","express":"^5.3.0","globals":"^17.6.0","@eslint/js":"^10.0.1","typescript":"^7.0.2","@types/node":"^20.19.43","@types/express":"^5.0.6"},"peerDependencies":{"express":">=4.0.0"},"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/http2-express_1.1.2_1795396102641_0.9579925822458643"}}},"time":{"created":"2024-11-04T00:54:05.443Z","modified":"2026-11-23T01:08:23.234Z","1.0.0":"2024-11-04T00:54:05.633Z","1.0.1":"2024-12-19T04:25:17.040Z","1.1.0":"2025-09-18T00:01:41.165Z","1.1.1":"2026-06-18T05:17:51.423Z","1.1.2":"2026-11-23T01:08:22.732Z"},"bugs":{"url":"https://github.com/markjovis/http2-express/issues"},"author":{"name":"Mark Jovis"},"license":"MIT","homepage":"https://github.com/markjovis/http2-express#readme","keywords":["express","http2","https","push","support","compatibility","api","server"],"repository":{"url":"git+https://github.com/markjovis/http2-express.git","type":"git"},"description":"HTTP/2 support for Express","contributors":[{"name":"grainrigi"}],"maintainers":[{"name":"markjovis","email":"mark.jovis@hotmail.com"}],"readme":"# http2-express\nThis package adds HTTP/2 support to express.js applications.\n\n**NOTICE**: Replacement for old `http2-express-bridge`: you only change the package name in the import.\n\n**http2-express** is a small package that lets an Express app run on Node's built-in `http2` server. Express is built on the HTTP/1.1 request and response classes and doesn't work with `http2` directly. This package makes the two compatible: you pass it the `express` module, get back a normal Express app, and hand that app to `http2.createSecureServer()` (or `http2.createServer()` for plain h2c).\n\n```javascript\nconst app = http2Express(express);\nhttp2.createSecureServer(options, app).listen(443);\n```\n**Limitation**: server push is not supported, because browsers have dropped it (Chrome removed it in version 106).\n\n## Installation\n```bash\nnpm i http2-express\n```\n\n**Notice**: It is recommended to use Node.js **version 19** or higher.\n\n## Usage\n- [CommonJS (CJS) usage](#common-js-cjs-usage).\n- [ES Modules (ESM) usage](#es-modules-esm-usage).\n- [TypeScript usage](#typescript-usage).\n\n## Version History\n**Version 1.1.2** includes **TypeScript** type definitions (no separate `@types` package needed for http2-express). The package works with both JavaScript and TypeScript, and with Express 4 and Express 5.\n<br>\n<br>\n\n**Version 1.1.1** Fixes the following bugs:\n1. Fixed the crash issue when a stream is already destroyed.\n2. Removed the side-effecting hostname getter that mutated this.headers['host']. The host header is now initialized once, upfront, in middleware.\n3. Wrapped Object.setPrototypeOf calls in try/catch so errors go to next(err) instead of hanging the request.\n4. Express5 detection now uses parseInt(express.version, 10) >= 5 with the old heuristic as fallback. No longer breaks if lazyrouter is monkey-patched.\n5. Removed response.push = () => {} which mutated the shared Express prototype; push no-ops are now set only on app._response and app.http2Response.\n6. Added headers['host'] initialization in the Express 5 router middleware.\n7. If Express is not installed in your project, or your installed Express version is below version 4.0.0, you'll get a warning.\n<br>\n<br>\n\n**Version 1.1.0** adds support for **EXPRESS 5**. [grainrigi](https://github.com/grainrigi) was able to make the changes necessary to support **EXPRESS 5**.\nThis version is also backward compatible with Express 4.\n<br>\n<br>\n\n**Version 1.0.1** fixes an issue with h2c (running HTTP/2 without TLS) as reported by rickardkarlsson. You should now be able to create a non https server (http2.createServer.....) without any issues.\n<br>\n<br>\n\n## Common JS (CJS) usage\n```javascript\nconst express = require('express');\nconst http2 = require('http2');\nconst http2Express = require('http2-express');\nconst fs = require('fs');\n\nconst app = http2Express(express);\n\napp.get('/', (req, res) => {\n  res.send('Hello World!');\n});\n\nconst options = {\n  key: fs.readFileSync('path to your certificate key'),\n  cert: fs.readFileSync('path to your certificate'),\n  passphrase: 'your certificate passphrase',\n  allowHTTP1: false\n};\n\nconst server = http2.createSecureServer(options, app);\n\nserver.listen(44320, () => {\n  console.info('Listening on port 44320...');\n});\n\n```\nThe code above creates an HTTP/2 server. An HTTP/2 server performs better than the older HTTP/1.1.\n\n**Notice**: If option property \"allowHTTP1\" is set to true, then your server will be backward compatible with HTTP/1.1. If false, then only the new HTTP/2 is supported. Browsers and HTTP Clients that don't support HTTP/2 will error out if \"allowHTTP1\" is false.\n\n\n## ES Modules (ESM) usage\nThe package works in both CommonJS (`require`) and ES module (`import`) projects, with Express 4 and Express 5. In an ESM project (`\"type\": \"module\"` in your `package.json`, or `.mjs` files), use a default import:\n```javascript\nimport express from 'express';\nimport http2 from 'http2';\nimport fs from 'fs';\nimport http2Express from 'http2-express';\n\nconst app = http2Express(express);\n\napp.get('/', (req, res) => {\n  res.send('Hello World!');\n});\n\n// ES modules have no __dirname; resolve files relative to this module with import.meta.url.\nconst options = {\n  key: fs.readFileSync(new URL('./certs/server-key.pem', import.meta.url)),\n  cert: fs.readFileSync(new URL('./certs/server-cert.pem', import.meta.url)),\n  passphrase: 'your certificate passphrase',\n  allowHTTP1: false\n};\n\nconst server = http2.createSecureServer(options, app);\n\nserver.listen(44320, () => {\n  console.info('Listening on port 44320...');\n});\n```\n\n## TypeScript usage\nType definitions ship with the package. Install the Express and Node.js types alongside it (use the `@types/express` major version that matches your Express version):\n```bash\nnpm i -D typescript @types/node @types/express\n```\n\n```typescript\nimport express from 'express';\nimport http2 from 'http2';\nimport fs from 'fs';\nimport http2Express from 'http2-express';\n\nconst app = http2Express(express);\n\napp.get('/', (req, res) => {\n  res.send('Hello World!');\n});\n\nconst options: http2.SecureServerOptions = {\n  key: fs.readFileSync('path to your certificate key'),\n  cert: fs.readFileSync('path to your certificate'),\n  passphrase: 'your certificate passphrase',\n  allowHTTP1: false\n};\n\nconst server = http2.createSecureServer(options, app);\n\nserver.listen(44320, () => {\n  console.info('Listening on port 44320...');\n});\n```\n`http2Express(express)` returns your regular, fully typed Express application (typed by whichever `@types/express` version you have installed) that can also be passed straight to `http2.createServer()` / `http2.createSecureServer()`. `esModuleInterop` must be enabled for the default `import` form above (it is on by default in current TypeScript); otherwise use `import http2Express = require('http2-express');`.\n<br>\n<br>\n\n## JSDoc type checking in JavaScript (no build step)\nIn plain JavaScript ESM or CJS, add `// @ts-check` at the top of a file (or `\"checkJs\": true` in a `jsconfig.json`) and your editor (VS Code, WebStorm, ...) or `tsc --noEmit` will check your code against the bundled type definitions. Nothing is compiled; the JavaScript runs as-is. This works the same in CommonJS (`require`) and ES module (`import`) files.\n```javascript\n// @ts-check\nconst express = require('express');\nconst http2 = require('http2');\nconst http2Express = require('http2-express');\n\n// The type is inferred automatically: your Express app, plus the HTTP/2 request listener signature.\nconst app = http2Express(express);\n\napp.get('/', (req, res) => {\n  res.send('Hello World!'); // req and res are fully typed; a typo like res.sendd() is flagged\n});\n\nconst server = http2.createServer(app);\n```\nYou normally don't need to write any type annotations, because the types are inferred as shown above.\n\nOptional: if you pass the app to a function in another place, TypeScript can't infer the parameter's type, so describe it with a JSDoc `@param`. This continues the example above and uses the same `app`:\n```javascript\n/**\n * The import(...) below is only a JSDoc type reference (it is not a runtime import),\n * so it also works in CommonJS files that use require().\n * @param {import('http2-express').Http2ExpressApplication<import('express').Express>} application\n */\nfunction registerHealthRoute(application) {\n  application.get('/health', (req, res) => {\n    res.send('ok'); // req and res are typed here too\n  });\n}\n\nregisterHealthRoute(app); // `app` from the example above\n```\nThe same `@types/express` / `@types/node` dev dependencies listed above are needed for editor/`tsc` checking. If you use TypeScript 7 and your project contains the npm `punycode` package, add `\"maxNodeModuleJsDepth\": 0` to your `jsconfig.json` to stop it from checking JavaScript inside `node_modules`.\n\nThe package's own source is annotated with JSDoc too, and `npm run typecheck` checks it, together with the type tests in `test/`.\n\n## Examples\nComplete working examples are in these [github](https://github.com/markjovis/http2-express) folders (each is a standalone project; run it with `npm start`, or check its types with `npm run typecheck`):\n\n| Folder | Language | Module system |\n| --- | --- | --- |\n| `example-express4-cjs`, `example-express5-cjs` | JavaScript (with `// @ts-check` and a `jsconfig.json`) | CommonJS (`require`) |\n| `example-express4-esm`, `example-express5-esm` | JavaScript (with `// @ts-check` and a `jsconfig.json`) | ES modules (`import`) |\n| `example-express4-ts`, `example-express5-ts` | TypeScript | compiled/run as CommonJS |\n","readmeFilename":"README.md"}