
Security News
Attackers Are Hunting High-Impact Node.js Maintainers in a Coordinated Social Engineering Campaign
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.
A lightweight, automatic file-based routing, inspired by Next.js-style dynamic routes.

A lightweight and flexible file-based routing system for Express.js, Hono, Diesel, or any other framework.
Note: Fastify requires a workaround using
setTimeout(100-200ms) to prevent errors.
fastify-autoload which is native fastify librarybun install ex-router
npm install ex-router
Import loadRoutes and initialize it with your app:
import express from 'express';
import { loadRoutes } from 'ex-router';
const app = express();
const port = 3000;
// Load routes
loadRoutes(app, {
routeDir: process.cwd() + '/src/routes',
prefixUrl: ''
});
app.get('/', (_, res) => {
res.send('Hello, world!');
});
app.listen(port, () => {
console.log(`Server is running on port ${port}`);
});
Note: Ensure your server file is in the root directory and
routesfolder is undersrc/.
example/
├── src/
│ ├── controller/
│ ├── routes/
│ │ ├── auth/
│ │ │ ├── login.ts
│ │ │ ├── register.js
│ │ ├── user/
│ │ │ ├── profile/
│ │ │ │ ├── index.ts
│ │ │ │ ├── delete.ts
│ │ │ │ ├── videos.ts
│ ├── utils/
│ ├── server.ts // root
loadRoutes(app, options)app - The application instance.options.routeDir - The directory containing route files.options.prefixUrl (optional) - A prefix for all routes.prefixUrl: '')File Path | API Route
------------------------------------|-----------
src/routes/hello.ts | /hello
src/routes/auth/login.ts | /auth/login
src/routes/user/profile/index.ts | /user/profile
src/routes/user/profile/videos.ts | /user/profile/videos
prefixUrl: '/api/v1')loadRoutes(app, {
routeDir: process.cwd() + '/src/routes',
prefixUrl: '/api/v1'
});
File Path | API Route
------------------------------------|-----------
src/routes/hello.ts | /api/v1/hello
src/routes/auth/login.ts | /api/v1/auth/login
src/routes/user/index.ts | /api/v1/user
src/routes/videos/api.ts | /api/v1/videos
src/routes/user/videos.ts | /api/v1/user/videos
Folders act as route segments
routes/user/profile.ts → /user/profileindex.ts or api.ts acts as the root
routes/user/index.ts → /userroutes/user/api.ts → /userroutes/user/profile/index.ts → /user/profileroutes/user/profile/api.ts → /user/profileMultiple HTTP Methods in a Single File
GET, POST, PUT, DELETE, etc.) within the same route file.export const GET = (req, res) => {
return res.send("Hello from login GET request.");
};
export const POST = (req, res) => {
const { username, password } = req.body;
if (!username || !password) {
return res.status(400).send("Username and password are required");
}
return res.send("Login successful");
};
import?This project is built with modern JavaScript standards. Use ES Modules (import statements) for better compatibility and maintainability.
Contributions are welcome! Feel free to submit issues or pull requests.
This project is licensed under the MIT License.
FAQs
A lightweight, automatic file-based routing, inspired by Next.js-style dynamic routes.
We found that ex-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.

Security News
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.

Security News
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.

Security News
Node.js has paused its bug bounty program after funding ended, removing payouts for vulnerability reports but keeping its security process unchanged.