corymb
v0.1.0
Published
Opinionated Bun backend framework: Better Auth (email/password + passkeys), PostgreSQL + PostgREST data API with RLS, Redis cache, jobs, storage, SSE realtime, security guards, flags, billing, webhooks, MCP and API docs.
Readme
corymb
An opinionated Bun backend framework, shipped as an npm package.
Authentication, PostgreSQL + PostgREST data with row-level security, caching, background jobs, object storage, realtime, security primitives, feature flags, billing entitlements, webhooks and MCP — wired together so you start with the plumbing instead of rebuilding it.
[!WARNING] Active development (pre-1.0).
corymbis under active development. The public API may change between minor releases until v1.0.0. Read the release notes before upgrading and pin an exact version in production. Bug reports and feedback are welcome.
Why corymb
- One package, one public API. Import from
corymb; never copy or depend on framework internals. Framework updates arrive through a version bump. - Auth is the only direct-database path. Better Auth owns the
authschema viaDATABASE_URL; application data goes through PostgREST so RLS applies to the verified Better Auth JWT. - Your routes win. Routes, middleware and WebSocket endpoints passed to
startServer()/createApp()are merged after the built-ins. - Production-oriented defaults. Request IDs, structured and redacted logs, unified errors, CORS, security headers, request limits, rate limiting and graceful shutdown are already in place.
- Bun-native.
Bun.serve,bun test,bun buildandbun --compileall work out of the box.
Consumer app
└─ startServer(options) / createApp(options)
├─ routing + composable middleware
├─ Better Auth → PostgreSQL auth schema (DATABASE_URL)
├─ PostgREST client → PostgreSQL app schema + RLS (POSTGREST_URL)
├─ cache (Redis or in-memory LRU)
├─ BullMQ jobs (Redis)
├─ object storage (S3 / filesystem / memory)
├─ audit, idempotency, rate limits, security guards
├─ feature flags + billing entitlements
├─ webhooks (outbound delivery, inbound verification)
├─ MCP endpoint (/mcp)
└─ realtime SSE + WebSocketsFeatures
| Area | Included |
| --- | --- |
| Auth | Better Auth email/password + username, session rotation, cookie/bearer/JWT sessions, JWKS for PostgREST, passkeys/WebAuthn, 2FA (email OTP, TOTP, backup codes), sensitive-operation step-up |
| Data | PostgreSQL auth schema via pg; PostgREST app schema with per-request JWT + RLS; typed query client; offset and cursor pagination; SQL migrations with status CLI; transactions, savepoints and Unit of Work |
| HTTP | Bun.serve routes, composable middleware registry, request validation, compression (br/gzip/deflate/zstd), signed cookies, multipart uploads, streaming/SSE, WebSockets, unified errors, security headers |
| Realtime | Authenticated SSE via Redis pub/sub (in-memory fallback), WebSocket endpoints with connection limits |
| Jobs & storage | BullMQ + Redis queue with retries, backoff and dead-letter; object storage adapters for S3-compatible services, filesystem and memory; pluggable mailer |
| Security | Tiered rate limiting (shared over Redis), request timeout and URL limits, CSRF double-submit, brute-force lockout, bot detection, SSRF guards and safeFetch, sanitize helpers |
| Operations | Validated typed config, structured redacted JSON logs, request IDs, audit events with pluggable sinks, Idempotency-Key protection, liveness/readiness probes |
| Product | Feature flags (env, cache-backed, OpenFeature), billing/entitlement gating, HMAC-signed outbound webhooks + inbound verification, MCP (Model Context Protocol) endpoint |
| Developer UX | Project scaffolding CLI, built-in API docs page, auth UI, sample routes, and a self-contained coding-agent skill |
Requirements
- Bun
>= 1.3.0 - PostgreSQL reachable at
DATABASE_URL(auth schema + migrations) - PostgREST reachable at
POSTGREST_URLfor application data - Redis (or Valkey) reachable at
REDIS_URL, unless you opt into the in-memory cache
Quick start (recommended)
Scaffold a project with the CLI:
bunx corymb init my-app
cd my-app
bun install
# edit .env — BETTER_AUTH_SECRET, DATABASE_URL, POSTGREST_URL; start Redis
bun run db:migrate # create the auth + app schemas
bunx corymb jwks # export postgrest/jwks.json for PostgREST
bun run devUse --force to overwrite a non-empty directory.
The scaffold includes sample routes (/api/health, /api/todos) that show how
to extend the server, run PostgREST queries scoped to the caller's JWT, record
audit events, publish SSE events and enqueue background jobs. See
docs/postgrest.md for roles, RLS and PostgREST
configuration.
Use as a library
bun add corymbimport {
createMemoryCache,
publishRealtimeEvent,
startServer,
withRateLimit,
} from 'corymb';
const { server, app, url } = await startServer({
// Optional: skip Redis for local experiments
// cache: createMemoryCache(),
routes: {
'/api/hello': {
GET: withRateLimit('relaxed', () => Response.json({ message: 'hello' })),
},
},
});
console.log(`listening on ${url.href}`);
await publishRealtimeEvent(app.events, {
type: 'widget.created',
data: { id: '1' },
at: Date.now(),
});Consumer routes are merged after the built-ins, so your path wins on conflict.
Prefer createApp() when you want to own Bun.serve yourself:
import { createApp } from 'corymb';
const app = await createApp({
/* options */
});
Bun.serve({
routes: app.routes,
fetch: app.fetchNotFound,
error: app.onServeError,
port: 3000,
});createApp() returns the app instance, routes, middleware, auth instance,
PostgREST client (app.data), cache, tasks, storage, audit recorder, flags,
billing, webhooks, logger and an idempotent close() for graceful shutdown. See
.env.example for every supported environment variable.
Run the built-in server as-is
bun add corymb
# configure .env (BETTER_AUTH_SECRET, DATABASE_URL, POSTGREST_URL, REDIS_URL)
bunx corymb
# or: bunx corymb startBuilt-in endpoints
| Endpoint | Description |
| --- | --- |
| GET /health | Liveness probe |
| GET /ready | Readiness probe (checks cache and PostgREST) |
| GET /docs | API docs page (gated by docsAccess / NODE_ENV) |
| GET /ui | Minimal auth UI (sign in/up, sign out, passkey management) |
| /api/auth/* | Better Auth handlers (sign-in/up, sessions, passkeys, 2FA, JWKS) |
| POST /upload | Multipart upload backed by the configured object storage |
| GET /realtime/events | Authenticated SSE stream |
| /mcp | MCP endpoint when enabled (MCP_ENABLED=true or mcp option) |
| GET /robots.txt | Generated robots.txt |
CLI
corymb Start the built-in server
corymb start Same as default
corymb init <dir> Scaffold a new consumer project (--force to overwrite)
corymb migrate Apply SQL migrations to DATABASE_URL
corymb migrate:status Show applied/pending migrations
corymb seed Migrate then seed demo users
corymb jwks [out] Export public JWKS for PostgRESTConfiguration
Configuration is validated at startup; loadAppConfig() reports every problem
in a single ConfigError. The common variables are:
| Variable | Purpose |
| --- | --- |
| BETTER_AUTH_SECRET | Auth signing secret, at least 32 characters (required) |
| BETTER_AUTH_URL | Public base URL used by Better Auth |
| DATABASE_URL | PostgreSQL connection for the auth schema and migrations |
| POSTGREST_URL | PostgREST endpoint for the app schema |
| REDIS_URL | Redis/Valkey URL (VALKEY_URL is accepted as an alias) |
| CACHE_DRIVER | redis (default) or memory |
| CORS_ORIGINS | Comma-separated browser origin allowlist |
| STORAGE_DRIVER | filesystem (default), s3 or memory |
| RATE_LIMIT_*_MAX | Strict/standard/relaxed limits per 60s window |
| BOT_DETECTION_MODE | block (default), log or off |
| FEATURE_FLAGS | JSON map or comma-separated flag list |
| MCP_ENABLED / MCP_TOKEN | Enable and secure the /mcp endpoint |
| REQUEST_TIMEOUT_MS / MAX_URL_LENGTH | Per-request limits |
The full annotated list lives in .env.example.
Agent skill
This repository ships a coding-agent skill that documents the whole framework —
scaffolding, app options, auth, PostgREST data, HTTP/middleware, cache, jobs,
storage, audit, idempotency, realtime, WebSockets, security, flags, billing,
webhooks, MCP, observability and testing. Install it globally with the
skills CLI:
npx skills add streamwhite/corymb -gIt works with OpenCode, Claude Code, Codex, Cursor and other agents. The skill
lives in
.opencode/skills/framework-development/
and is self-contained: a main SKILL.md plus focused references/*.md.
Develop this repository
bun install
cp .env.example .env # fill in BETTER_AUTH_SECRET, DATABASE_URL, POSTGREST_URL
bun run db:migrate:prd # apply auth/app schema migrations
bun run dev # watch mode
bun test # unit + integration tests (local PostgreSQL; or set TEST_DATABASE_URL)
bun run build # bundle dist/ (library + CLI + types + migrations)
bun run start # run the built server
bun run lint # biomePublishing (maintainers):
bun run build
bun publish # prepack runs the build automaticallyThe package publishes dist/ (bundled library + CLI + .d.ts types + SQL
migrations), plus README.md, LICENSE, .env.example, docs/ and
postgrest/.
Status and scope
corymb is in active development. The public API is being stabilised and
may change in minor releases until v1.0.0. Expect the largest changes around
app options, data helpers and optional modules.
What is intentionally out of scope:
- Your business logic and domain models.
- A hosted control plane, dashboard or managed PostgREST/Redis deployment.
- Encryption/key-management infrastructure (use your platform's KMS/secrets).
- Full Supabase feature parity. Some adjacent features are not implemented yet.
PostgREST is a first-class requirement for application data access. If you do not want to run it, use the direct-database helpers for your own service layer, but you lose the RLS-per-request model that the framework is built around.
Docs
- Database configuration
- Two-factor auth, transactions, migrations & Unit of Work
- PostgREST data layer (JWT + RLS)
- Config, logging, errors, audit & tasks
- Session lifetime and rotation
- Bot detection
- Realtime SSE usage
- ADR 0001: auth exception
License
Apache-2.0 © 2026 corymb contributors.
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in this project is licensed under the Apache License 2.0, without additional terms or conditions.
