{"_id":"@baseland-io/express-request-id","name":"@baseland-io/express-request-id","dist-tags":{"latest":"4.0.0"},"versions":{"4.0.0":{"name":"@baseland-io/express-request-id","version":"4.0.0","description":"Middleware to generate UUID for expressjs requests","license":"MIT","repository":{"type":"git","url":"git+https://github.com/baseland-io/express-request-id.git"},"author":{"name":"Developers","email":"developers@baseland.io"},"bugs":{"url":"https://github.com/baseland-io/express-request-id/issues"},"homepage":"https://github.com/baseland-io/express-request-id#readme","main":"dist/index.js","types":"dist/types.ts","prepublish":"npm run build","engines":{"node":"^18.x"},"scripts":{"build":"tsc","lint":"eslint ./","test":"LOG_LEVEL=off nyc mocha --config .mocharc.json"},"keywords":["express","middleware","request","id","uuid"],"dependencies":{"uuid":"^9.0.1"},"devDependencies":{"@baseland-io/eslint-config-baseland":"^0.1.5","@istanbuljs/nyc-config-typescript":"^1.0.2","@types/chai":"^4.3.11","@types/express":"^4.17.21","@types/express-serve-static-core":"^4.17.41","@types/mocha":"^10.0.6","@types/supertest":"^6.0.1","@types/uuid":"^9.0.4","@typescript-eslint/parser":"^6.16.0","chai":"^4.3.10","eslint":"^8.56.0","eslint-plugin-import":"^2.29.1","express":"^4.18.2","express-serve-static-core":"^0.1.1","mocha":"^10.2.0","nyc":"^15.1.0","supertest":"^6.3.3","ts-node":"^10.9.2","typescript":"^5.3.3"},"_id":"@baseland-io/express-request-id@4.0.0","gitHead":"768a7138717968a8f725a8ce9a03d1b9f039b978","_nodeVersion":"18.19.0","_npmVersion":"10.2.3","dist":{"integrity":"sha512-iHhbAornmFSOXTD+qO2PKdOrA0EJ4ORkU9VpbiqhKvOoMx0IfbbtBCdSN1R5vZaaXPuwoF4Uy4Bdxyp00Z7fAg==","shasum":"a23bc7343ac1f25ebe44ffa41a7d6d673f413058","tarball":"https://registry.npmjs.org/@baseland-io/express-request-id/-/express-request-id-4.0.0.tgz","fileCount":26,"unpackedSize":19912,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIEP5wKOELUAgYrFltVA5q1X453mO9nJx5xAMyWNAuIZ2AiBBuHE3wH1V+tpzGrI3xLIdfIGKOYTKhvkdjgmL1fxlGw=="}]},"_npmUser":{"name":"xzela","email":"zeph@lafassett.com"},"directories":{},"maintainers":[{"name":"xzela","email":"zeph@lafassett.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/express-request-id_4.0.0_1703863345690_0.09910179318330736"},"_hasShrinkwrap":false}},"time":{"created":"2023-12-29T15:22:25.551Z","4.0.0":"2023-12-29T15:22:25.838Z","modified":"2023-12-29T15:22:26.158Z"},"maintainers":[{"name":"xzela","email":"zeph@lafassett.com"}],"description":"Middleware to generate UUID for expressjs requests","homepage":"https://github.com/baseland-io/express-request-id#readme","keywords":["express","middleware","request","id","uuid"],"repository":{"type":"git","url":"git+https://github.com/baseland-io/express-request-id.git"},"author":{"name":"Developers","email":"developers@baseland.io"},"bugs":{"url":"https://github.com/baseland-io/express-request-id/issues"},"license":"MIT","readme":"# @baseland-io/express-request-id\n\n[![Tests](https://github.com/baseland-io/express-request-id/workflows/CI/badge.svg)](https://github.com/baseland-io/express-request-id/actions)\n[![npm version](https://img.shields.io/npm/v/@baseland-io/express-request-id.svg)](https://npmjs.org/package/@baseland-io/express-request-id 'View this project on NPM')\n[![npm downloads](https://img.shields.io/npm/dm/@baseland-io/express-request-id)](https://www.npmjs.com/package/@baseland-io/express-request-id)\n\nGenerates UUID for ExpressJS requests. Add an `id` property to the Request object.\n\n## Install\n\n```sh\nnpm install --save @baseland-io/express-request-id\n```\n\n## Basic Usage\n\n```js\nimport express from 'express';\nimport expressRequestId from '@baseland-io/express-request-id';\nconst PORT = 3000;\napp.use(expressRequestId());\n\napp.get('/', function (req, res, next) {\n  console.log('Res id: %s', res.get('X-Request-Id'));\n  return res.send(req.id);\n});\n\napp.listen(PORT, function() {\n  console.log('Listening on port %d', PORT);\n});\n\n// curl localhost:3000\n// Res id: e462be8c-5641-4b37-99c1-b0f16b859d2a\n// e462be8c-5641-4b37-99c1-b0f16b859d2a\n```\n\n## Custom Options Usage\n\n```ts\nimport express from 'express';\nimport expressRequestId, { Options } from '@baseland-io/express-request-id';\nconst PORT = 3000;\nconst options: Options = {\n  headerName: 'pizza-id',\n  setHeader: false,\n  generator: () => `pizza_${Math.random()}`;\n};\napp.use(expressRequestId(options));\n\napp.get('/', function (req, res, next) {\n  console.log('Res id: %s', res.get('pizza-id'));\n  return res.send(req.id);\n});\n\napp.listen(PORT, function() {\n  console.log('Listening on port %d', PORT);\n});\n\n// curl localhost:3000\n// Response id: undefined\n// pizza_0.36206992526026704\n```\n\n\n## Options\n| Property | Type | Default Value | Description |\n| --- | --- | --- | --- |\n| `headerName` | `string` | `'X-Request-Id'` | Defines name of header, that should be used for request ID checking and setting. |\n| `generator` | `function` | `(req) => uuidv4()` | A function that generates a string to be used as a unique id for each request. By default the [`uuid`](https://github.com/uuidjs/uuid) module is used to generated a v4 UUID for every request. |\n| `setHeader` | `boolean` | `true` | Sets the response `X-Request-Id` header (or custom header name). If `false` response header will not be set.  |\n","readmeFilename":"README.md"}