Content Engine
Content Engine Overview
Declare a content type once in TypeScript and get a Postgres table, Zod schemas, CRUD routes, staff permissions, and AdminCP screens.
Content Engine eliminates boilerplate for structured data. From a single TypeScript definition, it automatically generates a PostgreSQL table, Zod validation schemas, Hono CRUD endpoints, staff permissions, and AdminCP data management screens.
Quick start
1. Declare the Definition
import { defineContentType, field } from "@vitnode/core/content"
export const categoryContentType = defineContentType({
id: "blog.category",
tableName: "blog_categories",
fields: {
name: field.text({ required: true, minLength: 2, maxLength: 100 }),
slug: field.slug({ from: "name", required: true }),
},
})2. Compile the Database Model
import { createContentModel } from "@vitnode/core/content/server"
import { categoryContentType } from "../content/category"
export const categoryContent = createContentModel(categoryContentType)
export const blog_categories = categoryContent.table3. Build & Migrate
Build and migrate
bun run build:plugins && bun run db:migratepnpm build:plugins && pnpm db:migratenpm run build:plugins && npm run db:migratePostgreSQL now contains your table, and AdminCP screens are ready at /admin/content/blog/categories.
Generated Features
| Layer | Output |
|---|---|
| Database | Drizzle schema table with foreign keys and index constraints |
| Validation | Strongly typed Zod schemas for create, update, and filter operations |
| Hono API | Complete CRUD endpoints with staff permission protection |
| AdminCP UI | Data table with cursor pagination, sorting, search, and AutoForm dialogs |
| Events | content.{id}.created, content.{id}.updated, and content.{id}.deleted |