| 1234567891011121314 |
- import controllers from './controllers/index.ts';
- export const router = (req: Request) => {
- const url = new URL(req.url);
- for (const controller of controllers) {
- if (
- (controller.path === '*' || controller.path === url.pathname) &&
- (controller.method === '*' || controller.method === req.method)
- ) {
- return controller.handler(req);
- }
- }
- return new Response('Not Found', { status: 404 });
- };
|