A Bun monorepo containing the api-gateway service.
- Bun 1.3 or newer
- Docker with Docker Compose
cp apps/api-gateway/.env.example apps/api-gateway/.env
bun install
bun run db:up
bun run devThe API gateway listens on http://localhost:3000 by default.
Check the service and its PostgreSQL connection:
curl http://localhost:3000/healthExample response:
{
"status": "ok",
"database": {
"status": "ok",
"latencyMs": 1.42
}
}The endpoint returns 503 Service Unavailable when the database query fails. Its
latency includes pool acquisition, network, and query time, so the first request
can be slower while Bun opens the initial PostgreSQL connection.
| Command | Description |
|---|---|
bun run dev |
Start the API gateway with file watching |
bun run start |
Start the API gateway |
bun run test |
Run all workspace tests |
bun run typecheck |
Type-check all workspaces |
bun run db:up |
Start PostgreSQL in Docker |
bun run db:down |
Stop PostgreSQL |
bun run db:generate |
Generate Drizzle migrations after schema changes |
bun run db:migrate |
Apply Drizzle migrations |
There are no domain tables or migrations in the initial scaffold. Add table
definitions to apps/api-gateway/src/db/schema.ts, then run
bun run db:generate and bun run db:migrate.
.
├── apps/
│ └── api-gateway/
│ ├── .env.example
│ ├── src/
│ │ ├── db/
│ │ ├── app.ts
│ │ └── index.ts
│ └── drizzle.config.ts
├── compose.yaml
└── package.json