brick.ts

Built-in Capabilities

Explore built-in framework plugins for CRUD, request logging, and interactive documentation.

llms.txt

Brick-TS ships with built-in capabilities and plugins for declarative database operations, request timing, health checks, and API documentation.

The CRUD Plugin (@brickkit/crud)

The primary resource plugin in Brick-TS is crud(), published in @brickkit/crud. It installs declarative, field-guarded operations onto any table resource:

src/services/catalog.ts
import {
  defineDatabase,
  defineService,
  sqliteTable,
  text,
} from "@brickkit/core";
import { crud } from "@brickkit/crud";

export const products = sqliteTable("products", {
  id: text("id")
    .primaryKey()
    .$defaultFn(() => crypto.randomUUID()),
  name: text("name").notNull(),
  price: text("price").notNull(),
});

const database = defineDatabase({ tables: { products } });
const service = defineService("catalog", { database });

// Install the CRUD plugin onto the product resource:
export const product = service
  .resource({ name: "product", table: products, id: products.id })
  .use(
    crud({
      access: "public",
      fields: {
        id: { read: true, filter: ["eq", "in"] },
        name: {
          read: true,
          create: true,
          update: true,
          filter: ["contains"],
          sort: true,
        },
        price: { read: true, create: true, update: true },
      },
    }),
  );

Schema

These columns match the Drizzle tables in the example. Defaults marked as application defaults run in Drizzle, rather than in SQL.

Table Name: products

FieldTypeDescription
idtextRow identifier. PK Default: crypto.randomUUID() (application)
nametextDisplay name.
pricetextProduct price stored as text.

For full field policy options, query filter syntax, and operations control, see Resources and CRUD.

Request Logging Plugin

Request timing and logging are enabled by default in brick(). Every incoming route is measured and logged with status code and duration:

src/server.ts
import { brick } from "@brickkit/core";

// Enabled by default:
const app = brick({
  requestLogging: true,
});

// Or customize options:
const customApp = brick({
  requestLogging: {
    enabled: true,
    logger: (msg) => console.log(msg),
  },
});

To disable logging entirely, pass requestLogging: false.

Interactive API Documentation

Interactive documentation is built into brick() and requires no separate middleware:

  • Scalar API Docs: Modern documentation available at /docs (e.g. http://localhost:4000/docs).
  • Swagger UI: Traditional Swagger documentation available at /swagger (e.g. http://localhost:4000/swagger).
  • Raw OpenAPI 3.1 Spec: Machine-readable specification at /openapi.json.

These documentation routes mount at the root and are not affected by prefix.

For configuration options and mounting custom reference routes, see OpenAPI 3.1 & Interactive Documentation.

Diagnostics & Health Check (/_health)

Every Brick server automatically mounts a diagnostics route at /_health:

curl http://localhost:4000/_health

Response:

{
  "status": "ok",
  "uptime": 12.45,
  "timestamp": 1728821400000
}

This endpoint is ideal for Kubernetes liveness/readiness probes, Docker health checks, and load balancer pinging.