TypeScript backend framework

Typed APIs with permissions in Postgres.

Start a TypeScript backend with sign-in, PostgreSQL, typed route contracts, and relationship permissions. Inspect the working notes feature, then build yours beside it.

Create a starter project

npm create dads@latest my-app
my-app/
  apps/
    customer/app.ts
    staff/app.ts
    web/
  domains/notes/
    access/index.ts
    contract/wire.ts
    server/routes.ts
    web-client/index.ts
  assembly/
Inspect the notes domain on GitHub ↗

Core framework guarantees

  • Typed HTTP contracts

    Define params, query, body, and response schemas once. Validate requests, emit OpenAPI, and type web clients from the same schema.

  • Permissions in Postgres

    Model access as typed relationships on your resources. Verify permissions inside the same PostgreSQL transaction as the write.

  • Explicit API composition

    Assemble separate customer and staff APIs from shared domain plugins. Each entrypoint mounts the routes it serves.

  • Enforced domain boundaries

    Run npx dad check boundaries during development and CI. Block cross-domain imports that bypass public entrypoints.

  1. Check the relationship

    The session identifies the caller. Dads checks the tenant view permission in PostgreSQL before parsing input or counting rate limits, returning 404 on denial.

  2. Validate the contract

    The route declares the tenant ID, pagination query, and response item. Those schemas drive runtime validation, OpenAPI output, and typed clients.

  3. Scope the query

    The handler filters both rows and total counts by the authorized tenant ID so every response stays inside that workspace.

Run the full starter stack

Docker Compose starts PostgreSQL, a web app, a customer API, and a staff API. Sign in, invite a teammate to a workspace, and verify which notes each account can read.

Walk through your first note

Local stack Node 24 · Docker Compose

Run npm run dev:mail to print the local verification link. Create a workspace, save a note, and trace the request through domains/notes.

Requires Node 24 and Docker with Compose v2. Browse the starter source.

Compose a second API

Mount domain plugins per entrypoint with composeApi. The customer API exposes notes, while the staff API exposes audit exports and omits the notes route.

Read the API composition guide
  return composeApi("customer", {
    services: [provider, starterAccess],
    routes: [
      tenantsPlugin,
      tenantPermissionsPlugin,
      notesPlugin,
      // dad:add domains
    ],
    jobs: [notesAttachmentWorker],
  });
  return composeApi("staff", {
    services: [provider, starterAccess],
    routes: [
      tenantsPlugin,
      tenantAuditExportPlugin,
      // dad:add domains
    ],
    jobs: [],
  });

Example request

GET /api/tenants/:tenantId/notes
API Workspace access Response
Customer Member 200 OK
Customer Revoked 404 Not Found
Staff Any 404 Not Found