Create Module
Scaffold a new Vobase module following established conventions.
Constraints
- Module names: lowercase alphanumeric + hyphens only (
/^[a-z0-9-]+$/) - Reserved names:
auth,mcp,health,api,system - Schema must be a non-empty object of Drizzle table definitions
- Routes must be a Hono router instance
- Money fields: use
integer(cents), never float - Status fields: use explicit string enums
- All mutations should be auditable
Steps
Create module directory at
src/modules/{module-name}/Create schema (
schema.ts):import { integer, sqliteTable, text } from 'drizzle-orm/sqlite-core'; import { nanoid } from '@vobase/core'; export const {tableName} = sqliteTable('{table_name}', { id: text('id').primaryKey().$defaultFn(nanoid), // Add domain columns here createdAt: integer('created_at', { mode: 'timestamp' }).$defaultFn(() => new Date()), });Create routes (
routes.ts):import { Hono } from 'hono'; import { getCtx } from '@vobase/core'; import { eq } from 'drizzle-orm'; import { {tableName} } from './schema'; const routes = new Hono(); routes.get('/', async (c) => { const { db } = getCtx(c); const items = await db.select().from({tableName}); return c.json(items); }); export { routes };Create module definition (
index.ts):import { defineModule } from '@vobase/core'; import * as schema from './schema'; import { routes } from './routes'; export const {moduleName}Module = defineModule({ name: '{module-name}', schema, routes, });Register the module in the app's module list (typically
server.tsorapp.ts).Sync schema: Remind user to run
bunx drizzle-kit push(dev) or generate a migration.
Optional additions
- Jobs: Create
jobs.tswithJobDefinition[]and add todefineModule({ jobs }). - Pages: Add
pagesrecord mapping route paths to component paths. - Seed: Add
seedasync function for dev data.