Skip to content

Generating Code

blix writes one file per call, from a template matching this framework’s own conventions. It never edits anything else — wiring a generated file into your app is always a separate, explicit step. This walks through generating a real route end to end, the same way it happened in hello-api.

package.json
{
"devDependencies": {
"@blixis-io/cli": "workspace:*"
}
}
Terminal window
pnpm exec blix generate controller health
created src/health/health.controller.ts
import { Controller, Get } from "@blixis-io/http";
@Controller("health")
export class HealthController {
@Get()
list() {
return [];
}
}

The generated file is a valid starting point, not a finished route — edit it like any other file you wrote yourself:

src/health/health.controller.ts
import { Controller, Get } from "@blixis-io/http";
@Controller("health")
export class HealthController {
@Get()
list() {
return [];
}
check() {
return { status: "ok" };
}
}

A single provider-less route doesn’t need its own module — list it directly in AppModule’s controllers:

src/app.module.ts
import { Module } from "@blixis-io/core";
import { HealthController } from "./health/health.controller.js";
// ...other imports
@Module({
imports: [/* ... */],
controllers: [HealthController],
})
export class AppModule {}

(For a route with real providers/guards behind it, generate a module too and import that instead — see Modules.)

Terminal window
curl localhost:3000/health
# {"status":"ok"}

Add --dry-run to any command to see the path and content without writing anything — useful for checking what a name normalizes to:

Terminal window
blix generate service PostTags --dry-run
Would create src/post-tags/post-tags.service.ts:
import { Injectable } from "@blixis-io/di";
@Injectable()
export class PostTagsService {}