Skip to content

Damba

An AI-friendly, schema-driven Express framework. Declare your entities and a service map once; Damba wires REST routes, validation, auth, docs, BullMQ queues, and Socket.io around them. Its flat, greppable conventions — no DSL magic — make every service easy for humans and AI coding agents to read, generate, and review.

Schemas / Entities  →  Services  →  Routes  →  Docs

What you get

  • AI-friendly by design — a predictable schema → service → route → docs shape and flat, greppable conventions (no DSL magic) that LLMs and coding agents can scaffold and review reliably.
  • Auto-generated CRUD from any TypeORM entity, with opt-in before / after hooks.
  • Typed behaviors — factory functions with first-class request context (api.DSave, api.env, api.enqueue, …).
  • Policies — composable authorization steps with stable JSON error shapes.
  • Realtime — Socket.io wrapped in the same tenant + correlation context as your HTTP routes.
  • Queues — BullMQ producers + listeners sharing the request ALS context, with tenant sharding.
  • Errors — central DambaError hierarchy producing standardized JSON responses.
  • Docs — generated API + Extras pages out of the box.

A 30-second taste

ts
import { createDambaService, type BehaviorOf, type DambaApi } from "damba-v2";
import { z } from "zod";
import { User } from "./entities/User";

const CreateUserBody = z.object({
  name:  z.string().min(1),
  email: z.string().email(),
});

const createUser: BehaviorOf = (api?: DambaApi) => async (e) => {
  const body = e.in.body;  // validated + parsed by the Zod schema
  const saved = await api!.DSave(body);
  return e.out.status(201).json(saved);
};

export default createDambaService({
  service: { name: "user", entity: User },
  behaviors: {
    "/users": {
      method: "POST",
      behavior: createUser,
      config: { validators: { body: CreateUserBody } },
    },
  },
});

That's the whole pattern. The route key is the path ("/users") and the verb is the method field, behaviors are typed factories, and api exposes a typed repository, env helpers, queue producers, and more.

Where to go from here

Released under the MIT License.