Check and Build
Routa validates the route graph before TypeScript ever runs, so contract mistakes surface as named diagnostics instead of deep inference errors. This guide covers the four commands that validate, generate, and compile, and when to reach for each.
Before You Start
Section titled “Before You Start”- A project that installs cleanly, since
checkandbuildshell out totsc. .routa/**/*.tsincluded intsconfig.json, or generated context types will not resolve.
-
Validate the route graph and typecheck. This is the command to run before every commit.
Terminal window npm run checkTerminal window pnpm run checkTerminal window yarn run checkTerminal window bun run check -
Refresh generated metadata on its own when you changed route structure and want the
.routa/diff as a separate reviewable step.Terminal window npm run generateTerminal window pnpm run generateTerminal window yarn run generateTerminal window bun run generate -
Compile to JavaScript when you are ready to deploy.
Terminal window npm run buildTerminal window pnpm run buildTerminal window yarn run buildTerminal window bun run build -
Print the resolved route table when you want to see what Routa actually registered.
Terminal window npx routa routesTerminal window pnpm exec routa routesTerminal window yarn exec routa routesTerminal window bunx routa routes
Verify
Section titled “Verify”routa check reports both phases and exits 0:
Routa validation passed for 4 route file(s).Running TypeScript check: tsc -p tsconfig.json --noEmitTypeScript check passed.Routa check passed.routa build emits JavaScript only after validation passes:
Routa build passed for 4 route file(s).What Each Command Does
Section titled “What Each Command Does”| Command | Validates | Writes routes.gen.ts |
Runs TypeScript |
|---|---|---|---|
routa check |
Yes | On success | tsc --noEmit |
routa generate |
Yes | On success | No |
routa build |
Yes | On success | tsc with emit |
routa routes |
Yes | On success | No |
Validation is the same in all four. It covers project structure, route discovery, duplicate paths, missing 2xx responses, duplicate schema names, handler result shapes, middleware ordering, middleware reject statuses, and deprecation replacement targets. See Diagnostics for every code these can produce.
In Continuous Integration
Section titled “In Continuous Integration”Because a successful validation rewrites .routa/routes.gen.ts, treat a dirty working
tree after generation as a failure. That catches a commit where source and metadata
disagree:
npx routa generatepnpm exec routa generateyarn exec routa generatebunx routa generategit diff --exit-code -- .routatest -z "$(git ls-files --others --exclude-standard -- .routa)"npx routa checkpnpm exec routa checkyarn exec routa checkbunx routa checknpx routa openapi breakingpnpm exec routa openapi breakingyarn exec routa openapi breakingbunx routa openapi breakingTroubleshooting
Section titled “Troubleshooting”| Problem | Fix |
|---|---|
ROUTA_PROJECT_REQUIRED |
Run the command from the project root. Routa requires package.json, tsconfig.json, src/, and src/routa.ts. |
TypeScript errors about ctx properties that should exist |
Metadata is stale. Run routa generate and typecheck again. |
routa build reports no errors but dist/ is empty |
tsconfig.json sets noEmit. Generated projects keep emit enabled for the build. |
| Validation passes locally and fails in CI | .routa/ was not committed. It is required, not a build artifact. |