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

  1. Config Resolution: Automatically reads your vite.config.ts or nitro.config.ts using jiti to determine your routes directory, server directory, and alias paths.

  2. 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 });
    });
  3. Ambient Type Generation: Emits .taser/types/routes.d.ts containing 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:

package.json
{
  "scripts": {
    "dev": "vite",
    "build": "vite build",
    "typecheck": "taser generate && tsc --noEmit"
  }
}

Next Steps