Skip to main content
zerotal

Documentation


Documentation / @zerotal/core / index / scanFileRoutes

Function: scanFileRoutes()

scanFileRoutes(baseDir, reloadId?): Promise<number>

Defined in: router/FileRouter.ts:394

Scan baseDir for route files and register them with the global Router.

Called from Application.fileBasedRouting() during the boot phase. Returns the number of individual method handlers registered.

Skipped files:

  • _middleware.ts files (middleware config, not routes)
  • *.test.ts / *.spec.ts files
  • Any file with a leading underscore (_*.ts)
  • .d.ts declaration files

Registration order: file-based routes are registered during boot, before routes/index.ts runs. Explicit routes registered afterward take precedence (last write wins in Router.state.routes).

Parameters

baseDir

string

reloadId?

string

When provided (during a hot-reload), route and middleware files are imported with ?t=<reloadId> appended so Bun creates a fresh module namespace instead of returning the cached version. Omit on first boot.

Returns

Promise<number>

The number of individual method handlers registered.