Hono · Drizzle · PostgreSQL · OpenAPI

Das Backend,
für sich allein.

REST, a typed SDK, realtime over WebSocket, auth, storage and an OpenAPI spec — with every access rule enforced by the database itself. Point it at your own Postgres, or run rebase dev and get one without installing anything. No admin panel required.

~/shopready
empty
  • Reads tables, enums, keys and foreign keys from the catalog.
  • Writes one defineTable module per table, the source of the API, the SDK and the panel.
  • Copies no rows. Changes nothing in the database.
Runs against your database, on your machine.

REST, ohne es zu schreiben

01 / 07

Jede Tabelle, die du freigibst, wird zu einem Endpoint

No controllers, no serializers, no validation middleware. Filtering, sorting, pagination and relation loading are query parameters, in a PostgREST-compatible syntax your team probably already knows.

Nested relations are addressable as paths, so a customer's orders are a URL rather than a join you hand-wrote.

die erzeugte Oberfläche
GET  /api/data/orders?status=eq.paid&total=gt.100
GET  /api/data/orders?or=(status.eq.paid,total.gt.500)
GET  /api/data/orders/42?include=customer,items
GET  /api/data/customers/7/orders
POST /api/data/orders
PUT  /api/data/orders/42
DEL  /api/data/orders/42
REST, über jede Tabellelive · click an endpoint
Endpointsclick to send
200 OK8ms
ResponseRLS · rebase.role() IN ('admin', 'editor')
[
  {
    "id": 1,
    "name": "Alice Vance",
    "role": "admin"
  },
  {
    "id": 2,
    "name": "Bob Chen",
    "role": "editor"
  }
]
OpenAPI 3.1 auto-generatedtx · SET LOCAL role

Der typisierte Client

02 / 07

Autovervollständigung, die aus deinem Schema kommt

rebase generate-sdk macht aus deinen Tabellen einen Database-Typ. Gib ihn dem Client, und Tabellennamen, Feldnamen, Filteroperatoren und Rückgabeformen werden zur Compile-Zeit geprüft — samt der Felder, die du in include angefordert hast.

Benenn eine Spalte in der Tabelle um, und die Aufrufstellen werden rot, bevor irgendetwas ausgeliefert wird. Das Repository, das die API konsumiert, muss nicht das sein, das sie definiert: --from <url> erzeugt denselben Client aus einem laufenden Backend, in einem Projekt ganz ohne eigenes Schema. Web-App, Panel und Mobile-Client bleiben je in ihrem eigenen Repo, und die CI findet einen veralteten Client vor einem Nutzer.

Die komplette SDK-Tour
src/orders.ts
// generated once by `rebase generate-sdk`
import { tablesDictionary, type Database } from "./generated/sdk/database.types";

const client = createRebaseClient<Database>({
  baseUrl: "https://api.example.com",
  tables: tablesDictionary,
});

// table names, column names and return types all autocomplete
const { data } = await client.data.orders
  .find({
    where: { status: ["==", "paid"] },
    include: ["customer"],
    limit: 50,
  });
app.ts — typisiert aus deinen Tabellenlive · generated types
src/routes/posts.ts✓ 0 type errors
1import { createRebaseClient } from '@rebasepro/client';
2import type { Database } from './generated/sdk/database.types';
3
4const client = createRebaseClient<Database>({ baseUrl: API_URL });
5
6const { data } = await client.data.
TypeScript 5.8 · @rebasepro/clientUTF-8Ln 6, Col 36

Realtime

03 / 07

Änderungen kommen an, egal wie sie gemacht wurden

listen() auf jeder Tabelle, und jedes Insert, Update und Delete landet über WebSocket beim Client. Subscriptions respektieren dieselbe Row-Level Security wie ein Read — einem Abonnenten wird nie eine Zeile zugestellt, die er nicht auch hätte abrufen können.

Schreibvorgänge außerhalb der API zählen ebenfalls — eine aus psql, einem Cron-Job oder Studios SQL-Editor geänderte Zeile löst dasselbe Event aus, weil die Change-Erfassung in der Datenbank passiert. Broadcast-Kanäle und Presence sind standardmäßig pro Instanz; setz realtime.bus auf { type: "postgres" }, und sie verteilen sich über LISTEN/NOTIFY auf alle Replikate — oder gib ihm einen eigenen Transport.

orders · four writers, one streamLISTEN/NOTIFY
  • RESTPATCH /api/data/orders/42your app
  • psqlUPDATE orders SET status = 'shipped' WHERE id = 42;a person at a terminal
  • cronUPDATE orders SET status = 'closed' WHERE …a scheduled job
  • StudioUPDATE orders … — run from the SQL editorthe admin panel

→ one change event: orders · UPDATE · id 42

→ each subscriber re-reads the row under its own access rules

Four ways to write to the orders table — the REST API, psql, a cron job and Studio's SQL editor — all produce the same change event, which each subscriber receives filtered by its own access rules.

Authorization

04 / 07

Die Regeln leben in Postgres, nicht in diesem Server

Anfragen laufen als eingeschränkte Datenbankrolle. Deine rls-Regeln kompilieren zu echten Row-Level-Security-Policies — eine Query, die nichts zurückgeben sollte, gibt nichts zurück, egal ob sie über das SDK, einen REST-Aufruf, das Admin-Panel, den API-Key eines Agenten oder eine psql-Sitzung kommt. Jede Tabelle muss ihr rls deklarieren, und eine, deren Regeln nichts erlauben, liefert keine Zeilen: die Voreinstellung ist geschlossen, nicht offen.

backend/schema/orders.tswas du schreibst
export const orders = defineTable("orders", {
  columns: { /* … customer_id, total, status */ },

  rls: [
    // customers see their own orders…
    { operation: "select", ownerField: "customer_id" },

    // …support can read and update all of them
    { operations: ["select", "update"],
      roles: ["support"] },
  ],
});
psql — was die Datenbank durchsetztgenerated
-- rebase schema generate → db push
ALTER TABLE orders ENABLE ROW LEVEL SECURITY;

CREATE POLICY orders_select_1f4c9ab ON orders
  FOR SELECT TO rebase_user
  USING (customer_id = rebase.uid());

CREATE POLICY orders_update_8b02e13 ON orders
  FOR UPDATE TO rebase_user
  USING (string_to_array(rebase.roles(), ',')
         && ARRAY['support']);

-- no policy for INSERT or DELETE:
-- nobody can insert or delete. Closed by default.
Das ganze Sicherheitsmodell·Schon auf Postgres? npx @rebasepro/rls-check liest DATABASE_URL und prüft es, ohne dass du etwas installierst.

Ein Server

05 / 07

Alles gemountet, nichts zusammengebaut

Das ist die Routing-Tabelle eines Standardprojekts — ein Prozess, ein Deployment, kein Service-Mesh zu zeichnen. Jede davon existiert, weil sie selbst zu bauen eine Woche kostet, die du lieber anders verbringst.

Ein Prozess ist die Voreinstellung, nicht die Decke. Derselbe Build startet auch als API, als Functions-Tier und als Worker — eine Variable pro Prozess entscheidet, welche Routen gemountet werden, welche Timer feuern und wer das Schema besitzt.

Topics and jobs. Publish an event, subscribe by name. One durable row per subscriber, each retrying on its own schedule — and a publish inside a transaction that rolls back never happened.

Webhooks. HMAC-signed outbound calls on insert, update and delete, with retries.

Row history. An audit trail per table: who changed what, when, and a revert.

Database branching. Isolated copies of the whole database for a feature or a test run — schema, rows and policies — with one command to switch your project onto one and back.

Email. SMTP for verification, password reset and your own transactional templates.

Backups. Role-complete dumps and restores, driven from the CLI or the admin API.

Multiple sources. Route different tables to different databases from one server.

rebase dev — mounted routes
  • /api/data/:tableCRUD, filters, sorting, pagination, relation includes, nested relation paths
  • /api/schema/tablesthe tables, columns, relations and policies, redacted per caller — what the admin panel reads
  • /api/auth/*sign-up, login, refresh, password reset, OAuth, MFA, roles
  • /api/storage/*upload, download, signed access — local, S3-compatible or GCS
  • /api/functions/:nameyour own Hono routes, auto-mounted from functions/
  • /api/cron/*scheduled jobs with run history and manual triggers
  • /api/docs · /api/swaggerOpenAPI 3.0 spec of the tables each caller may see; an explorer when you publish it
  • /api/metathe runtime contract: schema version, runtime, tables
  • /healthreadiness for your orchestrator — asserts the auth schema, not just TCP
  • WebSocketrow subscriptions, broadcast channels and presence on the same server
Folders

Underneath

06 / 07

Langweilige Technik, mit Absicht

Eine Hono-App und ein Drizzle-Schema. Zwei Dinge, die dein Team lesen, debuggen und erweitern kann, ohne ein Framework zu lernen — und ohne darauf zu warten, dass wir einen Hook freigeben.

backend/src/index.tsHono
import { initializeRebaseBackend } from "@rebasepro/server";
import { createPostgresAdapter } from "@rebasepro/server-postgres";

const backend = await initializeRebaseBackend({
  server,
  app,
  schemaDir: path.resolve(__dirname, "../schema"),
  database: createPostgresAdapter({
    connection: db,
    schema: { tables, enums, relations },
  }),
  auth: { jwtSecret: process.env.JWT_SECRET },
  storage: { type: "local", basePath: "./uploads" },
});
// it's a Hono app — mount it, wrap it, add your own middleware
  • Als Sub-App auf einem Server einhängen, den du schon betreibst
  • Deine Middleware, deine Routen, dein Error-Handling
  • Node, Docker, Railway, Fly.io oder Bare Metal
Relationen, in einer Query aufgelöstDrizzle
// one table, one relation
export const posts = defineTable("posts", {
  columns: {
    id: col.uuid().primaryKey().defaultRandom(),
    title: col.text().notNull(),
  },
  relations: { author: rel.belongsTo(() => users) },
  rls: "inherit",
});

// GET /api/data/posts?include=author
// → one query via db.query.findMany, not 1 + N
  • One-to-one, one-to-many und many-to-many
  • Feldauswahl — hol genau die Spalten, nach denen du gefragt hast
  • Cursor- und Offset-Pagination

Die andere Hälfte

07 / 07

Headless als Standard

Das Admin-Panel ist ein Client dieser API, keine Schicht darin. Es liest durch dieselben Policies wie deine App. Schalte es unten ein: Das Projekt bekommt ein Frontend und eine Anpassungsdatei, ein Admin-Panel erscheint — und die API-Antwort rechts bewegt sich nicht.

A headless project: no frontend, no panel — just the API.

Your project

backend/
schema/users.ts

Dependencies

  • @rebasepro/server
  • @rebasepro/server-postgres
  • @rebasepro/client

A table has no presentation keys, so nothing about a panel can live in the backend.

backend/schema/users.ts

export const users = defineAuthTable("users", {
  columns: {
    id: col.uuid().primaryKey().defaultRandom(),
    email: col.text().notNull().unique(),
    displayName: col.text(),
  },
  // everyone reads their own row; admins list all
  rls: [{ operation: "select", roles: ["admin"] }],
});
// frontend/src/cms/users.tsx
customizeTable<typeof users>("users", {
  icon: "Users",
  group: "Settings",
  listFields: ["displayName", "email"],
});

The server loads the table either way — and never sees the customization.

Your API

identical
GET /api/data/users
200 OK · application/json
[{ "id": "9f2…", "email": "ada@…",
   "displayName": "Ada" }]

Admin panel

Not installed.

Nothing is served, nothing is bundled.

The only thing that changed is what a human can see.

Loslegen

Richte es auf deine Datenbank.

Scaffolde ein Projekt und lies die REST-Routen, das OpenAPI-Dokument und die erzeugten Policies.

Kein Account · Kein Docker · Lokales Postgres inklusive · MIT