{"id":26731020,"url":"https://github.com/web-server-userland/fastify-request-id","last_synced_at":"2025-04-14T10:22:48.015Z","repository":{"id":57699142,"uuid":"511363330","full_name":"web-server-userland/fastify-request-id","owner":"web-server-userland","description":"Fastify Request ID Plugin","archived":false,"fork":false,"pushed_at":"2022-10-21T03:48:23.000Z","size":66,"stargazers_count":4,"open_issues_count":0,"forks_count":2,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-27T23:33:48.300Z","etag":null,"topics":["fastify","javascript","nodejs"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/web-server-userland.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2022-07-07T02:57:44.000Z","updated_at":"2023-08-27T11:30:08.000Z","dependencies_parsed_at":"2022-08-26T16:31:12.722Z","dependency_job_id":null,"html_url":"https://github.com/web-server-userland/fastify-request-id","commit_stats":null,"previous_names":["fastify-userland/request-id"],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/web-server-userland%2Ffastify-request-id","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/web-server-userland%2Ffastify-request-id/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/web-server-userland%2Ffastify-request-id/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/web-server-userland%2Ffastify-request-id/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/web-server-userland","download_url":"https://codeload.github.com/web-server-userland/fastify-request-id/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248860244,"owners_count":21173390,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["fastify","javascript","nodejs"],"created_at":"2025-03-27T23:34:22.375Z","updated_at":"2025-04-14T10:22:47.985Z","avatar_url":"https://github.com/web-server-userland.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# @web-server-userland/fastify-request-id\n\n![CI](https://github.com/web-server-userland/request-id/workflows/CI/badge.svg)\n[![NPM version](https://img.shields.io/npm/v/@web-server-userland/fastify-request-id.svg?style=flat)](https://www.npmjs.com/package/@web-server-userland/fastify-request-id)\n[![js-standard-style](https://img.shields.io/badge/code%20style-standard-brightgreen.svg?style=flat)](https://standardjs.com/)\n[![NPM size](https://img.shields.io/bundlephobia/min/@web-server-userland/fastify-request-id)](https://www.npmjs.com/package/@web-server-userland/fastify-request-id)\n[![Coverage Status](https://coveralls.io/repos/github/web-server-userland/fastify-request-id/badge.svg?branch=main)](https://coveralls.io/github/web-server-userland/fastify-request-id?branch=main)\n\nA plugin for Fastify that adds support for `request-id` and `session-id`.\n\nSupports Fastify versions 4.x.\n\n\u003e Support TypeScript\n\n## Install\n\n```shell\n# npm\nnpm i @web-server-userland/fastify-request-id\n\n# pnpm\npnpm add @web-server-userland/fastify-request-id\n\n# yarn\nyarn add @web-server-userland/fastify-request-id\n```\n\n## Usage\n\n```JavaScript\nconst fastify = require('fastify')()\n\nfastify.register(require('@web-server-userland/fastify-request-id'), {\n  // put your options here\n})\n\nfastify.get('/', (req, reply) =\u003e {\n  console.log(req.reqID, req.sesID, req.ids)\n  reply.send({ hello: 'world' }) // =\u003e response header has `x-request-id` and `x-session-id`\n})\n\nfastify.listen(3000)\n```\n\nYou can use it as is without passing any option or you can configure it as explained below.\n\n### Options\n\n* `generateHash`: Generate hash. For example:\n\n```javascript\n/**\n * @params {\"requestID\" | \"sessionID\"} type - will generate type hash\n */\ngenerateHash: (type) =\u003e {\n  if (type === \"requestID\") {\n    return `req${uuidv4()}`\n  }\n  if (type === \"sessionID\") {\n    return `ses${uuidv4()}`\n  }\n}\n```\n\n* `requestIDName`: request id name - *default: `x-request-id`*\n\n* `sessionIDName`: session id name - *default: `x-session-id`*\n\n## License\n\nLicensed under [MIT](./LICENSE).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fweb-server-userland%2Ffastify-request-id","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fweb-server-userland%2Ffastify-request-id","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fweb-server-userland%2Ffastify-request-id/lists"}