{"id":14969162,"url":"https://github.com/fastify/fastify-routes","last_synced_at":"2025-04-08T11:12:24.576Z","repository":{"id":33005311,"uuid":"150737919","full_name":"fastify/fastify-routes","owner":"fastify","description":"Decorates fastify instance with a map of routes","archived":false,"fork":false,"pushed_at":"2025-03-30T21:31:25.000Z","size":144,"stargazers_count":119,"open_issues_count":0,"forks_count":15,"subscribers_count":16,"default_branch":"main","last_synced_at":"2025-04-01T10:10:26.886Z","etag":null,"topics":["fastify","fastify-plugin"],"latest_commit_sha":null,"homepage":"https://npmjs.com/package/@fastify/routes","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/fastify.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"github":"fastify","open_collective":"fastify"}},"created_at":"2018-09-28T12:34:01.000Z","updated_at":"2025-03-30T21:31:28.000Z","dependencies_parsed_at":"2023-01-14T23:00:39.858Z","dependency_job_id":"b6854f19-33df-446d-b966-f9f893ce30d0","html_url":"https://github.com/fastify/fastify-routes","commit_stats":{"total_commits":117,"total_committers":24,"mean_commits":4.875,"dds":0.5982905982905983,"last_synced_commit":"518f56b2a9cd484dcaf077da1accee4619eb9f8a"},"previous_names":[],"tags_count":13,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fastify%2Ffastify-routes","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fastify%2Ffastify-routes/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fastify%2Ffastify-routes/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fastify%2Ffastify-routes/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/fastify","download_url":"https://codeload.github.com/fastify/fastify-routes/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247829511,"owners_count":21002997,"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","fastify-plugin"],"created_at":"2024-09-24T13:41:15.332Z","updated_at":"2025-04-08T11:12:24.547Z","avatar_url":"https://github.com/fastify.png","language":"JavaScript","readme":"# @fastify/routes\n\n[![CI](https://github.com/fastify/fastify-routes/actions/workflows/ci.yml/badge.svg?branch=main)](https://github.com/fastify/fastify-routes/actions/workflows/ci.yml)\n[![NPM version](https://img.shields.io/npm/v/@fastify/routes.svg?style=flat)](https://www.npmjs.com/package/@fastify/routes)\n[![neostandard javascript style](https://img.shields.io/badge/code_style-neostandard-brightgreen?style=flat)](https://github.com/neostandard/neostandard)\n\nThis plugin decorates a Fastify instance with `routes`, which is a [Map](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map) of registered routes. Note that you have to await the registration of this plugin before registering any routes so that @fastify/routes can collect them.\n\n## Data Structure\n\nThe `fastify.routes` Map has a key for each path any route has been registered, which points to an array of routes registered on that path. There can be more than one route for a given path if there are multiple routes added with different methods or different constraints.\n\n```js\n  {\n    '/hello': [\n      {\n        method: 'GET',\n        url: '/hello',\n        schema: { ... },\n        handler: Function,\n        prefix: String,\n        logLevel: String,\n        bodyLimit: Number,\n        constraints: undefined,\n      },\n      {\n        method: 'POST',\n        url: '/hello',\n        schema: { ... },\n        handler: Function,\n        prefix: String,\n        logLevel: String,\n        bodyLimit: Number,\n        constraints: { ... },\n      }\n    ]\n  }\n```\n\n## Example\n\n```js\nconst fastify = require(\"fastify\")();\n\n(async () =\u003e {\n  await fastify.register(require(\"@fastify/routes\"));\n  fastify.get(\"/hello\", {}, (request, reply) =\u003e {\n    reply.send({ hello: \"world\" });\n  });\n\n  fastify.listen({ port: 3000 }, (err, address) =\u003e {\n    if (err) {\n      console.error(err);\n      return;\n    }\n    console.log(fastify.routes);\n    /* will output a Map with entries:\n    {\n      '/hello': [\n        {\n          method: 'GET',\n          url: '/hello',\n          schema: Object,\n          handler: \u003cFunction\u003e,\n          prefix: \u003cString\u003e,\n          logLevel: \u003cString\u003e,\n          bodyLimit: \u003cNumber\u003e\n        }\n      ]\n    }\n    */\n  });\n})();\n```\n\n## License\n\nMIT License\n","funding_links":["https://github.com/sponsors/fastify","https://opencollective.com/fastify"],"categories":["JavaScript"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffastify%2Ffastify-routes","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffastify%2Ffastify-routes","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffastify%2Ffastify-routes/lists"}