{"id":15097855,"url":"https://github.com/kasa-network/koa-request-id","last_synced_at":"2025-10-08T02:31:52.138Z","repository":{"id":57124037,"uuid":"155158663","full_name":"kasa-network/koa-request-id","owner":"kasa-network","description":"A middleware that adds a request id in Koa","archived":true,"fork":false,"pushed_at":"2019-03-09T15:47:52.000Z","size":18,"stargazers_count":5,"open_issues_count":0,"forks_count":0,"subscribers_count":18,"default_branch":"master","last_synced_at":"2025-08-08T18:37:35.674Z","etag":null,"topics":["correlation-id","koa","koa-middleware","koa2","koa2-middleware","reqid","request-id","tracing"],"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/kasa-network.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","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":"2018-10-29T05:51:53.000Z","updated_at":"2023-01-28T08:58:14.000Z","dependencies_parsed_at":"2022-08-31T07:51:28.337Z","dependency_job_id":null,"html_url":"https://github.com/kasa-network/koa-request-id","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"purl":"pkg:github/kasa-network/koa-request-id","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kasa-network%2Fkoa-request-id","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kasa-network%2Fkoa-request-id/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kasa-network%2Fkoa-request-id/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kasa-network%2Fkoa-request-id/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/kasa-network","download_url":"https://codeload.github.com/kasa-network/koa-request-id/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kasa-network%2Fkoa-request-id/sbom","scorecard":{"id":551081,"data":{"date":"2025-08-11","repo":{"name":"github.com/kasa-network/koa-request-id","commit":"723e910d91ee2495e6b3d88bccf18b107894d805"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":3,"checks":[{"name":"Dangerous-Workflow","score":-1,"reason":"no workflows found","details":null,"documentation":{"short":"Determines if the project's GitHub Action workflows avoid dangerous patterns.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#dangerous-workflow"}},{"name":"Maintained","score":0,"reason":"project is archived","details":["Warn: Repository is archived."],"documentation":{"short":"Determines if the project is \"actively maintained\".","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#maintained"}},{"name":"Code-Review","score":0,"reason":"Found 0/27 approved changesets -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project requires human code review before pull requests (aka merge requests) are merged.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#code-review"}},{"name":"SAST","score":0,"reason":"no SAST tool detected","details":["Warn: no pull requests merged into dev branch"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}},{"name":"Token-Permissions","score":-1,"reason":"No tokens found","details":null,"documentation":{"short":"Determines if the project's workflows follow the principle of least privilege.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#token-permissions"}},{"name":"Binary-Artifacts","score":10,"reason":"no binaries found in the repo","details":null,"documentation":{"short":"Determines if the project has generated executable (binary) artifacts in the source repository.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#binary-artifacts"}},{"name":"Packaging","score":-1,"reason":"packaging workflow not detected","details":["Warn: no GitHub/GitLab publishing workflow detected."],"documentation":{"short":"Determines if the project is published as a package that others can easily download, install, easily update, and uninstall.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#packaging"}},{"name":"Pinned-Dependencies","score":-1,"reason":"no dependencies found","details":null,"documentation":{"short":"Determines if the project has declared and pinned the dependencies of its build process.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#pinned-dependencies"}},{"name":"CII-Best-Practices","score":0,"reason":"no effort to earn an OpenSSF best practices badge detected","details":null,"documentation":{"short":"Determines if the project has an OpenSSF (formerly CII) Best Practices Badge.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#cii-best-practices"}},{"name":"Security-Policy","score":0,"reason":"security policy file not detected","details":["Warn: no security policy file detected","Warn: no security file to analyze","Warn: no security file to analyze","Warn: no security file to analyze"],"documentation":{"short":"Determines if the project has published a security policy.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#security-policy"}},{"name":"Fuzzing","score":0,"reason":"project is not fuzzed","details":["Warn: no fuzzer integrations found"],"documentation":{"short":"Determines if the project uses fuzzing.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#fuzzing"}},{"name":"Vulnerabilities","score":10,"reason":"0 existing vulnerabilities detected","details":null,"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#vulnerabilities"}},{"name":"Signed-Releases","score":-1,"reason":"no releases found","details":null,"documentation":{"short":"Determines if the project cryptographically signs release artifacts.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#signed-releases"}},{"name":"License","score":10,"reason":"license file detected","details":["Info: project has a license file: LICENSE:0","Info: FSF or OSI recognized license: MIT License: LICENSE:0"],"documentation":{"short":"Determines if the project has defined a license.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#license"}},{"name":"Branch-Protection","score":0,"reason":"branch protection not enabled on development/release branches","details":["Warn: branch protection not enabled for branch 'master'"],"documentation":{"short":"Determines if the default and release branches are protected with GitHub's branch protection settings.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#branch-protection"}}]},"last_synced_at":"2025-08-20T10:52:25.192Z","repository_id":57124037,"created_at":"2025-08-20T10:52:25.192Z","updated_at":"2025-08-20T10:52:25.192Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":278877658,"owners_count":26061490,"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","status":"online","status_checked_at":"2025-10-08T02:00:06.501Z","response_time":56,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["correlation-id","koa","koa-middleware","koa2","koa2-middleware","reqid","request-id","tracing"],"created_at":"2024-09-25T16:40:56.659Z","updated_at":"2025-10-08T02:31:51.877Z","avatar_url":"https://github.com/kasa-network.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003cdiv align=\"center\"\u003e\n  \u003ch1\u003e@kasa/koa-request-id\u003c/h1\u003e\n\u003c/div\u003e\n\n\u003cp align=\"center\"\u003e\n  A middleware that generates a unique Request ID for every incoming HTTP request in Koa.\n\u003c/p\u003e\n\n\u003cdiv align=\"center\"\u003e\n  \u003ca href=\"https://circleci.com/gh/kasa-network/koa-request-id\"\u003e\n    \u003cimg alt=\"CircleCI\" src=\"https://circleci.com/gh/kasa-network/koa-request-id.svg?style=shield\" /\u003e\n  \u003c/a\u003e\n  \u003ca href=\"https://coveralls.io/github/kasa-network/koa-request-id\"\u003e\n    \u003cimg src=\"https://coveralls.io/repos/github/kasa-network/koa-request-id/badge.svg\" alt='Coverage Status' /\u003e\n  \u003c/a\u003e\n  \u003ca href=\"https://badge.fury.io/js/@kasa/koa-request-id\"\u003e\n    \u003cimg alt=\"npm version\" src=\"https://img.shields.io/npm/v/@kasa/koa-request-id.svg\" /\u003e\n  \u003c/a\u003e\n  \u003ca href=\"https://david-dm.org/kasa-network/koa-request-id\"\u003e\n    \u003cimg alt=\"npm\" src=\"https://img.shields.io/david/kasa-network/koa-request-id.svg?style=flat-square\" /\u003e\n  \u003c/a\u003e\n  \u003ca href=\"https://opensource.org/licenses/mit-license.php\"\u003e\n    \u003cimg alt=\"MIT Licence\" src=\"https://badges.frapsoft.com/os/mit/mit.svg?v=103\" /\u003e\n  \u003c/a\u003e\n  \u003ca href=\"https://github.com/ellerbrock/open-source-badge/\"\u003e\n    \u003cimg alt=\"Open Source Love\" src=\"https://badges.frapsoft.com/os/v1/open-source.svg?v=103\" /\u003e\n  \u003c/a\u003e\n\u003c/div\u003e\n\n\u003cbr /\u003e\n\n\n## Installation\n\n```bash\n# Using NPM\n$ npm install --save @kasa/koa-request-id\n# Using Yarn\n$ yarn add @kasa/koa-request-id\n```\n\n\n### Dependencies\n\n- [**Koa**](https://github.com/koajs/koa) 2.0+\n- [**Node.js**](https://nodejs.org) 8.0.0+\n\n\n## Usage\n\nUse `koa-request-id` as a middleware for a [koa](https://github.com/koajs/koa) app. By default, it generates a unique uuid (v4) and exposes it on the response via the `X-Request-Id` header. The id is also saved as part of the request *state*.\n\nIn the following example, the generated uuid is manually exposed on the body for debugging purposes:\n\n```js\nconst Koa = require('koa');\nconst requestId = require('@kasa/koa-request-id');\nconst app = new Koa();\n\napp.use(requestId());\napp.use(async ctx =\u003e {\n  ctx.body = ctx.state.reqId;\n});\n\napp.listen(3000);\n```\n\nExecute a request to the running app:\n\n```bash\n❯ curl -v http://localhost:3000\n\n\u003c HTTP/1.1 200 OK\n\u003c X-Request-Id: a78598a4-6537-45eb-811c-fdc59602a54c\n\na78598a4-6537-45eb-811c-fdc59602a54c\n```\n\nSometimes it is also useful to pass a custom id via a request header, specifically in tracking requests on the distributed system. Please note that the input id is not sanitized, so the usual precautions apply.\n\nUsing the above snippet to send a custom via the default `X-Request-Id` header:\n\n```bash\n❯ curl -v -H 'X-Request-Id: foobar' http://localhost:3000\n\n\u003c HTTP/1.1 200 OK\n\u003c X-Request-Id: foobar\n\nfoobar\n```\n\n\n## API\n\n### Creating an middleware\n\nYou can create a new request id middleware by passing the relevant options to `requestId`;\n\n```node\n// With default options\nconst middleware = requestId({\n  query: null,\n  header: 'X-Request-Id',\n  exposeHeader: 'X-Request-Id',\n  generator: require('uuid/v4')\n});\n```\n\n### Middleware Configuration\n\nThese are the available config options for the middleware. All is optional. The middleware try to get the request id from `X-Request-Id` request header or generate a new request id using `uuidv4` generator. Then, the request id will be set into `ctx.state.reqId` Koa context state object and `X-Request-Id` response header if any option is not specified.\n\n```node\n{\n  // Request query name to get the forwarded request id\n  query: 'reqId',\n\n  // Request header name to get the forwarded request id\n  header: 'X-Transaction-Id',\n\n  // Response header name\n  exposeHeader: 'X-Transaction-Id',\n\n  // Function to generate request id\n  generator: () =\u003e Date.now().toString()\n}\n```\n\n\n## Contributing\n\n#### Bug Reports \u0026 Feature Requests\n\nPlease use the [issue tracker](https://github.com/kasa-network/koa-request-id/issues) to report any bugs or ask feature requests.\n\n\n## License\n\nProvided under the terms of the [MIT License](https://github.com/kasa-network/koa-request-id/blob/master/LICENSE).\n\nCopyright © 2018-2019, [Kasa](http://www.kasa.network).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkasa-network%2Fkoa-request-id","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkasa-network%2Fkoa-request-id","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkasa-network%2Fkoa-request-id/lists"}