
Company News
/Security News
Socket Selected for OpenAI's Cybersecurity Grant Program
Socket is an initial recipient of OpenAI's Cybersecurity Grant Program, which commits $10M in API credits to defenders securing open source software.
node-file-router
Advanced tools

A powerful file-based routing for Node.js.
It simplifies the creation and organization of API services. You can effortlessly map your project's file structure to your API endpoints, enabling a clear and maintainable codebase.
Imagine you have a project with the following structure:
api/
├── profile/
│ ├── middlware.ts - middleware for profile
│ └── orders.[post].ts - methods in any filenames
├── catalog/
│ └── [[...tags]].ts - several segments
├── collection/
│ └── [cid]/ - slugs in folders
│ └── products/
│ └── [pid].ts - slugs in files
├── index.ts - root
├── middleware.ts - middleware for all routes
└── _404.ts - not found response
Node File Router will automatically map it to your API endpoints:
/api/profile/orders.[post].ts/api/catalog/[[...tags]].ts/api/collection/[cid]/products/[pid].tsindex.tsSome examples of how your file handlers can be written:
Methods in a file
export default {
get(req, res, routeParams) {},
post(req, res, routeParams) {},
patch(req, res, routeParams) {},
}
Single response function
export default function (req, res, routeParams) {}
Middlewares chain
export default [
useErrorHandler,
useLogger,
useAuthGuard,
];
Classes
export default class Resource {
get(req, res, routeParams) {}
post(req, res, routeParams) {}
patch(req, res, routeParams) {}
}
npm i node-file-router
Visit website to get started and view the full documentation.
Usage:
Methods routing:
Route matching:
Support other protocols and frameworks:
Middlewares:
Visit examples folder to see samples with different module systems, adapters, and use cases.
I usually respond within 24 hours. Fixes typically take 1-3 days. Additionally, I provide time estimations for new features and fixes. Feel free to ask questions, voice ideas, and share your projects on Github Discussion.
To begin development and contribution, read this guide.
FAQs
A powerful file-based routing for Express.js, Bun, pure Node.js and more
The npm package node-file-router receives a total of 544 weekly downloads. As such, node-file-router popularity was classified as not popular.
We found that node-file-router demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Company News
/Security News
Socket is an initial recipient of OpenAI's Cybersecurity Grant Program, which commits $10M in API credits to defenders securing open source software.

Security News
Socket CEO Feross Aboukhadijeh joins 10 Minutes or Less, a podcast by Ali Rohde, to discuss the recent surge in open source supply chain attacks.

Research
/Security News
Campaign of 108 extensions harvests identities, steals sessions, and adds backdoors to browsers, all tied to the same C2 infrastructure.