Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/guide/server-routing.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ Create route handlers in `routes/**/*.ts`. Each file maps to a URL path based on

<RoutesFileTree />

Dynamic segments use brackets: `[id]` becomes a route parameter and `[...slug]` becomes a catch-all. Files or directories starting with `_` are ignored. Directories wrapped in parentheses like `(admin)` are route groups. They help organize files without changing the URL.
Dynamic segments use brackets: `[id]` becomes a route parameter and `[...slug]` becomes a catch-all. Files or directories starting with `_` are ignored, and so are those starting with `.`, except `.well-known`. Directories wrapped in parentheses like `(admin)` are route groups. They help organize files without changing the URL.

### Environment-only routes

Expand Down
6 changes: 3 additions & 3 deletions packages/void/src/shared/convention-files.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { globSync } from 'tinyglobby';

/** Handler files under `dir`, relative to it, skipping paths with a `_`-prefixed segment. */
export function listConventionFiles(dir: string): Array<string> {
return globSync('**/*.{ts,mts,js,mjs}', { cwd: dir }).filter(
(filePath) => !filePath.split('/').some((segment) => segment.startsWith('_')),
);
return globSync(['**/*.{ts,mts,js,mjs}', '.well-known/**/*.{ts,mts,js,mjs}'], {
cwd: dir,
}).filter((filePath) => !filePath.split('/').some((segment) => segment.startsWith('_')));
}
8 changes: 8 additions & 0 deletions packages/void/test/unit/scan.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,14 @@ describe('scanRoutes', () => {
expect(result.routes[0].pattern).toBe('/api/hello');
});

it('discovers routes under .well-known and ignores other dot paths', async () => {
createFile('routes/.well-known/security.txt.ts');
createFile('routes/.cache/hello.ts');

const result = await scanRoutes(TMP);
expect(result.routes.map((route) => route.pattern)).toEqual(['/.well-known/security.txt']);
});

it('discovers and sorts middleware by numeric prefix', async () => {
createFile('middleware/02.auth.ts');
createFile('middleware/01.logger.ts');
Expand Down