-
Notifications
You must be signed in to change notification settings - Fork 12
Open
Labels
bugSomething isn't workingSomething isn't working
Description
I'm not sure if I'm doing things wrong or misunderstanding the docs, but I'm running into some problems with Express 5.
import { dirname, join } from 'node:path';
import { fileURLToPath } from 'node:url';
import express from 'express';
import initFileRouter from 'express-file-routing';
const __dirname = dirname(fileURLToPath(import.meta.url));
const app = express();
await initFileRouter(app, { directory: join(__dirname, 'routes') });
app.listen(port, () => {
console.log(`Server is running on http://localhost:${port}`);
});
Then, in my routes folder I have loads of different routes, and I put the following file anywhere within my routes
folder:
// I tried routes/[...catchall].ts, routes/api/[...catchall].ts, etc etc etc...
import type { Request, Response } from 'express';
export default async function (req: Request, res: Response) {
const path = req.params[0]
res.json({
path
});
}
Upon server start I now get an error. It always looks the same, except for the number shown after Missing parameter name at
, which changes based on the position of the [...catchall].ts
file in the routes
folder.
TypeError: Missing parameter name at 2: https://git.new/pathToRegexpError
at name (/home/user/fantome/fantome/node_modules/.pnpm/path-to-regexp@8.2.0/node_modules/path-to-regexp/dist/index.js:73:19)
at lexer (/home/user/fantome/fantome/node_modules/.pnpm/path-to-regexp@8.2.0/node_modules/path-to-regexp/dist/index.js:91:27)
at lexer.next (<anonymous>)
at Iter.peek (/home/user/fantome/fantome/node_modules/.pnpm/path-to-regexp@8.2.0/node_modules/path-to-regexp/dist/index.js:106:38)
at Iter.tryConsume (/home/user/fantome/fantome/node_modules/.pnpm/path-to-regexp@8.2.0/node_modules/path-to-regexp/dist/index.js:112:28)
at Iter.text (/home/user/fantome/fantome/node_modules/.pnpm/path-to-regexp@8.2.0/node_modules/path-to-regexp/dist/index.js:128:30)
at consume (/home/user/fantome/fantome/node_modules/.pnpm/path-to-regexp@8.2.0/node_modules/path-to-regexp/dist/index.js:152:29)
at parse (/home/user/fantome/fantome/node_modules/.pnpm/path-to-regexp@8.2.0/node_modules/path-to-regexp/dist/index.js:183:20)
at /home/user/fantome/fantome/node_modules/.pnpm/path-to-regexp@8.2.0/node_modules/path-to-regexp/dist/index.js:294:74
at Array.map (<anonymous>)
Am I doing something wrong?
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working