File-System Routingfor Modern Express.js Applications
Type-safe route configuration through directory structure
with built-in middleware support and automatic endpoint discovery
routes/user/[id].get.ts
import { RequestHandler } from 'express';
export const handler: RequestHandler = (req, res) => {
res.json({ userId: req.params.id });
};
File-System Routing
Automatic route mapping from directory structure
routes/users/[id].get.ts → /users/:id
Middleware Support
File/directory-level middleware handling
index.middleware.ts
Dynamic Parameters
Named parameter handling with validation
[param] → req.params.param
Type Safety
TypeScript-first architecture
export const handler: RequestHandler
Error Handling
Centralized error handling
index.error.ts
HTTP Methods
Native method handlers
GET, POST, PUT, PATCH, DELETE, OPTIONS, HEAD ...