{"id":13678439,"url":"https://github.com/Danilqa/node-file-router","last_synced_at":"2025-04-29T13:31:00.586Z","repository":{"id":186912308,"uuid":"637060774","full_name":"Danilqa/node-file-router","owner":"Danilqa","description":"💫  A file-based routing for Node.js. Works with Bun, pure Node.js, Express.js, and more!","archived":false,"fork":false,"pushed_at":"2025-03-15T05:57:05.000Z","size":2408,"stargazers_count":190,"open_issues_count":4,"forks_count":5,"subscribers_count":4,"default_branch":"main","last_synced_at":"2025-04-12T15:58:25.635Z","etag":null,"topics":["auto","auto-routing","bun","express","middleware","nodejs","router","routing","typescript"],"latest_commit_sha":null,"homepage":"https://node-file-router.js.org","language":"TypeScript","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/Danilqa.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":"SECURITY.md","support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-05-06T11:39:36.000Z","updated_at":"2025-04-07T09:48:18.000Z","dependencies_parsed_at":null,"dependency_job_id":"da9ad5bf-33f9-4439-aca5-f434783d511d","html_url":"https://github.com/Danilqa/node-file-router","commit_stats":{"total_commits":144,"total_committers":2,"mean_commits":72.0,"dds":0.01388888888888884,"last_synced_commit":"b0c30e88794d1debf2cfe7cf7051f049eb84a45d"},"previous_names":["danilqa/node-file-router"],"tags_count":10,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Danilqa%2Fnode-file-router","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Danilqa%2Fnode-file-router/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Danilqa%2Fnode-file-router/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Danilqa%2Fnode-file-router/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Danilqa","download_url":"https://codeload.github.com/Danilqa/node-file-router/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":251509445,"owners_count":21600638,"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":["auto","auto-routing","bun","express","middleware","nodejs","router","routing","typescript"],"created_at":"2024-08-02T13:00:53.644Z","updated_at":"2025-04-29T13:31:00.576Z","avatar_url":"https://github.com/Danilqa.png","language":"TypeScript","funding_links":[],"categories":["TypeScript","typescript"],"sub_categories":[],"readme":"# Node File Router\n\n\u003cimg align=\"right\" width=\"92\" height=\"92\" title=\"Node File Router Logo\"\nsrc=\"./static/images/logo.png\" /\u003e\n\n[![product of the week](./static/images/devhunt-badge.svg)](https://devhunt.org/tool/node-file-router)\n\n[![Codacy Badge](https://api.codacy.com/project/badge/Grade/f0e2838a1ddf48a89bec571a0f692834)](https://app.codacy.com/gh/Danilqa/node-file-router?utm_source=github.com\u0026utm_medium=referral\u0026utm_content=Danilqa/node-file-router\u0026utm_campaign=Badge_Grade)\n[![ci Status](https://github.com/danilqa/node-file-router/actions/workflows/deploy.yml/badge.svg)](https://github.com/Danilqa/node-file-router/actions)\n[![npm downloads](https://snyk.io/test/github/danilqa/node-file-router/badge.svg)](https://snyk.io/test/github/danilqa/node-file-router)\n[![license](https://img.shields.io/badge/license-MIT-blue.svg)](https://github.com/danilqa/node-file-router/blob/main/LICENSE)\n\nA powerful file-based routing for Node.js. \n\nIt simplifies the creation and organization of API services.\nYou can effortlessly map your project's file structure to your API endpoints, enabling a clear and maintainable codebase.\n\n* **Technology Agnostic**: \n  * Express\n  * Pure Node HTTP\n  * Bun\n  * Sockets\n  * ... whatever compatible with the interface\n* **0** dependencies\n* **CommonJS** and **ES modules** support\n* **TypeScript** support\n* **100%** test coverage\n* **Middlewares** support\n\n# Overview\n\nImagine you have a project with the following structure:\n```\napi/\n├── profile/\n│   ├── middlware.ts - middleware for profile\n│   └── orders.[post].ts - methods in any filenames\n├── catalog/\n│   └── [[...tags]].ts - several segments\n├── collection/\n│   └── [cid]/ - slugs in folders\n│       └── products/\n│           └── [pid].ts - slugs in files\n├── index.ts - root\n├── middleware.ts - middleware for all routes\n└── _404.ts - not found response    \n```\n\nNode File Router will automatically map it to your API endpoints:\n* [POST]: /profile/orders → `/api/profile/orders.[post].ts`\n* /catalog/men/black/denim → `/api/catalog/[[...tags]].ts`\n* /collection/77/products/13 → `/api/collection/[cid]/products/[pid].ts`\n* / → `index.ts`\n\nSome examples of how your file handlers can be written:\n\nMethods in a file\n```js\nexport default {\n  get(req, res, routeParams) {},\n  post(req, res, routeParams) {},\n  patch(req, res, routeParams) {},\n}\n```\n\nSingle response function\n```js\nexport default function (req, res, routeParams) {}\n```\n\nMiddlewares chain\n```js\nexport default [\n  useErrorHandler,\n  useLogger,\n  useAuthGuard,\n];\n```\n\nClasses\n```js\nexport default class Resource {\n  get(req, res, routeParams) {}\n  \n  post(req, res, routeParams) {}\n  \n  patch(req, res, routeParams) {}\n}\n```\n\n# Documentation\n\n```bash\nnpm i node-file-router\n```\n\nVisit [website](https://node-file-router.js.org/) to get started and view \nthe full documentation.\n\nUsage:\n* [Getting started](https://node-file-router.js.org/docs/getting-started)\n* [Usage guide](https://node-file-router.js.org/docs/usage-guide)\n  * [Configuration](https://node-file-router.js.org/docs/usage-guide#configuration)\n* [Usage with Bun](https://node-file-router.js.org/docs/use-with-bun)\n* [Get All Registered Routes](https://node-file-router.js.org/docs/usage-guide#get-all-registered-routes)\n\nMethods routing:\n* [Any method](https://node-file-router.js.org/docs/usage-guide#any-method)\n* [Object with methods](https://node-file-router.js.org/docs/usage-guide#object-with-methods)\n* [Class with methods](https://node-file-router.js.org/docs/usage-guide#class-with-methods)\n* [Methods in filenames](https://node-file-router.js.org/docs/usage-guide#methods-in-filenames)\n\nRoute matching:\n* [Plain match](https://node-file-router.js.org/docs/route-matching#direct-matching) - /plain/route/\n* [Exact slug](https://node-file-router.js.org/docs/route-matching#exact-matching) - /[id]/\n* [Catching all](https://node-file-router.js.org/docs/route-matching#catching-all) - /[id1]/[id2]/[idn]/\n* [Optional catching all](https://node-file-router.js.org/docs/route-matching#optional-catching-all) - ?/[id1]/[id2]/[idn]/\n\nSupport other protocols and frameworks:\n* [Custom adapter](https://node-file-router.js.org/docs/custom-adapter)\n\nMiddlewares:\n* [Usage and examples](https://node-file-router.js.org/docs/middlewares)\n\n# Examples\n\nVisit [examples folder](https://github.com/Danilqa/node-file-router/tree/main/examples) to see samples with \ndifferent module systems, adapters, and use cases.\n\n# Support\n\nI usually respond within 24 hours. Fixes typically take 1-3 days. Additionally, I provide time estimations for \nnew features and fixes. Feel free to ask questions, voice ideas, and share your projects on [Github Discussion](https://github.com/Danilqa/node-file-router/discussions).\n\n# Developing\n\nTo begin development and contribution, read [this guide](/contributing/developing.md).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FDanilqa%2Fnode-file-router","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FDanilqa%2Fnode-file-router","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FDanilqa%2Fnode-file-router/lists"}