{"_id":"@allstak/express","_rev":"2-0c6837c547e0b3b67a824b0c73177333","name":"@allstak/express","dist-tags":{"beta":"0.1.0","latest":"0.1.1"},"versions":{"0.1.0":{"name":"@allstak/express","version":"0.1.0","license":"MIT","_id":"@allstak/express@0.1.0","maintainers":[{"name":"allstak-","email":"hello@allstak.sa"}],"homepage":"https://allstak.sa","bugs":{"url":"https://github.com/AllStak/allstak-express/issues"},"dist":{"shasum":"bc9143f26316267c38fb846ad578e17d28baf616","tarball":"https://registry.npmjs.org/@allstak/express/-/express-0.1.0.tgz","fileCount":10,"integrity":"sha512-LFzYa+4Ws7pFhWRa//jJSUhTHlchTPR3y0wA2+wRTun8DxYZn6YiC443gLrLhbueJocsQTABYGEAsFxosmzQDA==","signatures":[{"sig":"MEYCIQDp3bob1aaYMcPlocKp47Tnxvc/i49vof/H8RW2PTdlOAIhAI/Ce1OOJqkUUK6YpdZVER0jZApLDBk6gITlQ5GYHmJ+","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"attestations":{"url":"https://registry.npmjs.org/-/npm/v1/attestations/@allstak%2fexpress@0.1.0","provenance":{"predicateType":"https://slsa.dev/provenance/v1"}},"unpackedSize":79404},"main":"./dist/index.js","_from":"file:/home/runner/work/allstak-express/allstak-express/pack/allstak-express-0.1.0.tgz","types":"./dist/index.d.ts","module":"./dist/index.mjs","engines":{"node":">=18"},"exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.mjs","require":"./dist/index.js"}},"scripts":{"test":"vitest run","build":"tsup","pack:dry":"npm pack --dry-run","typecheck":"tsc --noEmit"},"_npmUser":{"name":"allstak-","email":"hello@allstak.sa"},"_resolved":"/home/runner/work/allstak-express/allstak-express/pack/allstak-express-0.1.0.tgz","_integrity":"sha512-LFzYa+4Ws7pFhWRa//jJSUhTHlchTPR3y0wA2+wRTun8DxYZn6YiC443gLrLhbueJocsQTABYGEAsFxosmzQDA==","repository":{"url":"git+https://github.com/AllStak/allstak-express.git","type":"git"},"_npmVersion":"10.8.2","description":"AllStak SDK for Express (beta). Auto-integration that wraps @allstak/js: request-span middleware, error-capture middleware, trace propagation, and a one-line setup.","directories":{},"_nodeVersion":"20.20.2","dependencies":{"@allstak/js":"^0.3.0"},"publishConfig":{"access":"public","registry":"https://registry.npmjs.org/"},"_hasShrinkwrap":false,"devDependencies":{"tsup":"^8.0.0","vitest":"^1.6.1","express":"^4.21.2","supertest":"^7.0.0","typescript":"^5.3.0","@types/node":"^20.0.0","@types/express":"^4.17.21","@types/supertest":"^6.0.2"},"peerDependencies":{"express":">=4.0.0"},"_npmOperationalInternal":{"tmp":"tmp/express_0.1.0_1780088440207_0.5116082159572748","host":"s3://npm-registry-packages-npm-production"}},"0.1.1":{"name":"@allstak/express","version":"0.1.1","description":"AllStak SDK for Express (beta). Auto-integration that wraps @allstak/js: request-span middleware, error-capture middleware, trace propagation, and a one-line setup.","main":"./dist/index.js","module":"./dist/index.mjs","types":"./dist/index.d.ts","exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.mjs","require":"./dist/index.js"}},"repository":{"type":"git","url":"git+https://github.com/AllStak/allstak-express.git"},"homepage":"https://allstak.sa","bugs":{"url":"https://github.com/AllStak/allstak-express/issues"},"publishConfig":{"access":"public","registry":"https://registry.npmjs.org/"},"scripts":{"build":"tsup","typecheck":"tsc --noEmit","test":"vitest run","pack:dry":"npm pack --dry-run"},"dependencies":{"@allstak/js":"^0.3.0"},"peerDependencies":{"express":">=4.0.0"},"devDependencies":{"@types/express":"^4.17.21","@types/node":"^20.0.0","@types/supertest":"^6.0.2","express":"^4.21.2","supertest":"^7.0.0","tsup":"^8.0.0","typescript":"^5.3.0","vitest":"^1.6.1"},"engines":{"node":">=18"},"license":"MIT","_id":"@allstak/express@0.1.1","_integrity":"sha512-KaLLTqyeqRDL/0g0bd9rJimS3dvpWpEHd6BZIUMbKLZcBI1p2m7vByXRSmgM18JRD8SHokKvKfdOOYpyicm3OA==","_resolved":"/home/runner/work/allstak-express/allstak-express/pack/allstak-express-0.1.1.tgz","_from":"file:/home/runner/work/allstak-express/allstak-express/pack/allstak-express-0.1.1.tgz","_nodeVersion":"20.20.2","_npmVersion":"10.8.2","dist":{"integrity":"sha512-KaLLTqyeqRDL/0g0bd9rJimS3dvpWpEHd6BZIUMbKLZcBI1p2m7vByXRSmgM18JRD8SHokKvKfdOOYpyicm3OA==","shasum":"3a56332f148aa007f606caf4c236556bda74f80e","tarball":"https://registry.npmjs.org/@allstak/express/-/express-0.1.1.tgz","fileCount":10,"unpackedSize":79709,"attestations":{"url":"https://registry.npmjs.org/-/npm/v1/attestations/@allstak%2fexpress@0.1.1","provenance":{"predicateType":"https://slsa.dev/provenance/v1"}},"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEUCIQC4Ze9XPDBFq8eXA4pLGBhRegAHdpPZ7fvRGXLPT39GsgIgKNga4A4f/ixuN7NKcnv0/N8k9wQ7wX8uH/1CAVFtiPA="}]},"_npmUser":{"name":"allstak-","email":"hello@allstak.sa"},"directories":{},"maintainers":[{"name":"allstak-","email":"hello@allstak.sa"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/express_0.1.1_1780099128126_0.5709718399009014"},"_hasShrinkwrap":false}},"time":{"created":"2026-05-29T21:00:39.901Z","modified":"2026-05-29T23:58:48.559Z","0.1.0":"2026-05-29T21:00:40.338Z","0.1.1":"2026-05-29T23:58:48.285Z"},"bugs":{"url":"https://github.com/AllStak/allstak-express/issues"},"license":"MIT","homepage":"https://allstak.sa","repository":{"type":"git","url":"git+https://github.com/AllStak/allstak-express.git"},"description":"AllStak SDK for Express (beta). Auto-integration that wraps @allstak/js: request-span middleware, error-capture middleware, trace propagation, and a one-line setup.","maintainers":[{"name":"allstak-","email":"hello@allstak.sa"}],"readme":"# @allstak/express\n\nAllStak SDK for Express. A thin auto-integration that wraps\n[`@allstak/js`](https://www.npmjs.com/package/@allstak/js): a request-span\nmiddleware, an error-capture middleware, inbound trace propagation, and a\none-line setup.\n\n## Install\n\n```bash\nnpm install @allstak/express @allstak/js\n```\n\nPeer dependency:\n\n```bash\nnpm install express\n```\n\n## One-line setup\n\n```ts\nimport express from 'express';\nimport { allstakExpress } from '@allstak/express';\n\nconst app = express();\n\n// Inits @allstak/js and mounts the request handler FIRST + error handler LAST.\nallstakExpress(app, {\n  apiKey: process.env.ALLSTAK_API_KEY,\n  environment: process.env.NODE_ENV ?? 'production',\n  release: process.env.ALLSTAK_RELEASE,\n  serviceName: 'api',\n});\n\napp.get('/users/:id', (req, res) => {\n  res.json({ id: req.params.id });\n});\n\napp.listen(3000);\n```\n\nBecause Express error-handling middleware must run after every route, `setup`\nmounts the request handler first and appends the error handler. For the common\n\"setup before routes\" order this is correct. If you register routes in a way\nthat needs full control, pass `mountErrorHandler: false` and mount the returned\nhandler yourself as the final `app.use`:\n\n```ts\nconst { errorHandler } = allstakExpress(app, {\n  apiKey: process.env.ALLSTAK_API_KEY,\n  mountErrorHandler: false,\n});\n\n// ... your routes ...\n\napp.use(errorHandler); // LAST\n```\n\n## Manual wiring\n\n```ts\nimport express from 'express';\nimport { AllStak } from '@allstak/js';\nimport { requestHandler, errorHandler } from '@allstak/express';\n\nAllStak.init({ apiKey: process.env.ALLSTAK_API_KEY });\n\nconst app = express();\n\napp.use(requestHandler()); // FIRST — opens the request span\n// ... your routes ...\napp.use(errorHandler());   // LAST — captures thrown / next(err) errors\n```\n\n`middleware()` is an alias for `requestHandler()`.\n\n## What is captured\n\n- Inbound HTTP request telemetry on response finish: method, route pattern,\n  status code, and round-trip duration via `AllStak.captureRequest`.\n- A server span per request (`http.server`) named by the route pattern.\n- Unhandled and `next(err)`-forwarded errors via `AllStak.captureException`,\n  with `method` / `path` / `statusCode` / `userAgent` in `requestContext`.\n- Inbound trace adoption from `X-AllStak-Trace-Id` / `X-Trace-Id` / W3C\n  `traceparent`, with the resolved trace id stamped back on the response.\n\n## Route-pattern naming\n\nSpans and request rows are named by the matched route *pattern*\n(`req.route?.path`, e.g. `/users/:id`), prefixed by the router mount point\n(`req.baseUrl`) — never the concrete URL (`/users/42`). This keeps telemetry\ncardinality low and groupable.\n\n## Options\n\n`allstakExpress(app, options)` accepts every `@allstak/js` `init` option plus:\n\n| Option | Description |\n| --- | --- |\n| `apiKey` | Project API key. Required unless `init: false`. |\n| `environment` | Deployment environment. |\n| `release` | App version or commit SHA. |\n| `serviceName` | Logical service name. |\n| `init` | Call `AllStak.init`. Default `true`. Set `false` if you already initialised `@allstak/js`. |\n| `mountErrorHandler` | Auto-mount the error handler as the final `app.use`. Default `true`. |\n| `request` | Options forwarded to the request-handler middleware. |\n\n## Reliability\n\nEvery code path is fail-open. A missing `AllStak.init`, a capture error, or an\ningest outage never breaks the customer's request or error pipeline.\n\n## Contributing and Support\n\n- Report bugs with the GitHub bug report template: https://github.com/AllStak/allstak-express/issues/new/choose\n- Open pull requests using the checklist in [CONTRIBUTING.md](CONTRIBUTING.md).\n- Report security vulnerabilities privately through [SECURITY.md](SECURITY.md).\n\n## License\n\nMIT\n","readmeFilename":"README.md"}