Skip to content

Code Generators

The velox make command scaffolds common code patterns for a single model at a time.

GeneratorAliasDescription
namespacensSchema + procedures from existing Prisma model
resourcer, resFull resource stack (Prisma model + schema + procedures + tests)
procedurep, procProcedure files
schemas, zodZod schemas
migrationmigPrisma migrations
modelmFull model setup
testt, specTest files

The fastest way to scaffold procedures for a single existing Prisma model:

  1. Define your Prisma model
  2. Run velox make namespace

The generator reads your Prisma schema, detects relations, and scaffolds type-safe procedures with the correct include clauses automatically.

prisma/schema.prisma
model Order {
id String @id @default(uuid())
total Float
status String @default("pending")
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
customer Customer @relation(fields: [customerId], references: [id])
customerId String
items OrderItem[]
@@map("orders")
}

Push the schema to your database:

Terminal window
pnpm db:push
Terminal window
velox make namespace Order --example

This creates three files and auto-registers the procedures in your router:

Created:
src/schemas/order.ts # Zod schemas (Create, Update, base)
src/procedures/orders.ts # CRUD procedures with Prisma queries
src/procedures/__tests__/orders.test.ts
Modified:
src/index.ts # Auto-registered orderProcedures

Because the generator detected the customer (belongsTo) and items (hasMany) relations in your Prisma schema, the generated queries include them automatically:

// Generated procedures include detected relations
getOrder: procedure()
.input(z.object({ id: z.string().uuid() }))
.query(async ({ input, ctx }) => {
return ctx.db.order.findUnique({
where: { id: input.id },
include: { customer: true, items: true },
});
}),
OptionShortDescription
--example-eInclude example CRUD procedures (recommended)
--with-tests-tGenerate test file (default: true)
--skip-registration-SSkip auto-registering in router.ts

Running without --example creates a minimal scaffold with commented-out procedure examples, ready for you to fill in:

Terminal window
velox make namespace Order

Creates everything from scratch: Prisma model, Zod schema, procedures, and tests.

Terminal window
velox make resource Product

Creates: model, schema, procedures, and tests.

Terminal window
velox make procedure users
velox make procedure posts --crud
Terminal window
velox make schema User
velox make schema Post --crud
Terminal window
velox make migration create_users_table
velox make migration add_email_to_users
OptionDescription
--crudInclude CRUD operations
--soft-deleteAdd deletedAt field
--paginationAdd paginated list
--dry-runPreview without writing
--jsonMachine-readable output
Terminal window
velox make procedure users --crud
Created: src/procedures/users.ts
- listUsers (GET /api/users)
- getUser (GET /api/users/:id)
- createUser (POST /api/users)
- updateUser (PUT /api/users/:id)
- deleteUser (DELETE /api/users/:id)