CLI & Type Generation
Generate ambient route types, scaffold empty endpoint files, and enforce pre-build CI checks with the @taserjs/router-cli developer tool.
The @taserjs/router-cli package provides command-line utilities to generate ambient TypeScript definitions and scaffold empty route files without running a development server.
Installation
@taserjs/router-cli is typically installed as a development dependency:
bash pnpm add -D @taserjs/router-cli taser generate
The generate command scans your routes directory, detects configuration from vite.config.ts or nitro.config.ts, scaffolds boilerplate for any blank route files, and writes ambient TypeScript types to .taser/types/routes.d.ts.
npx taser generate [options]CLI Options
Prop
Type
How It Works
-
Config Resolution: Automatically reads your
vite.config.tsornitro.config.tsusingjitito determine your routes directory, server directory, and alias paths. -
Automatic Route Scaffolding: If any new route or layout file is empty (such as after
touch src/routes/admin/users.get.ts), the CLI automatically populates it with starter boilerplate:src/routes/admin/users.get.ts import { json } from "@taserjs/router/reply"; import { t } from "@taserjs/router"; const GET = t.get("/admin/users"); export type RouteContext = typeof GET.$Infer.Context; export default GET.handler((_ctx) => { return json({ ok: true }); }); -
Ambient Type Generation: Emits
.taser/types/routes.d.tscontaining the global router type and route definitions, enabling full IDE autocomplete even when the Vite dev server is not active.
CI / CD and Typecheck Integration
Because Vite manages hot module reloading and virtual modules during development (vite dev), taser generate is primarily used in CI/CD pipelines and standalone typecheck scripts before running tsc:
{
"scripts": {
"dev": "vite",
"build": "vite build",
"typecheck": "taser generate && tsc --noEmit"
}
}Next Steps
Typed Client SDK
Connect to Taser.js backends with end-to-end type safety using @taserjs/router-client. Enjoy autocomplete for routes, query schemas, and return types.
@taserjs/router
Complete API reference for @taserjs/router: createTaserApp, createContext, fluent RouteBuilder chaining, reply helpers, and core types.