API Key
Set up, configure, and run the Reloop API key microservice locally.
Complete Base Setup First
Ensure you've finished the Setup — before proceeding.
Service Overview
Generation, hashing, validation, and revocation of developer API keys.
| Property | Value |
|---|---|
| Directory | apps/backend/api-key |
| Port | 8012 |
| Local URL | https://local.reloop.sh/api/api-key |
| Swagger UI | https://local.reloop.sh/api/api-key/openapi |
| Stack | ElysiaJS Better Auth API Key PostgreSQL Redis NATS |
Quick Start
Run from the monorepo root:
bun be:api-key:dev
The service starts with hot reloading on port 8012.
Environment Configuration
Variables live in apps/backend/api-key/.env. Running bun env:setup from the root auto-populates this file.
PG_URL=postgresql://reloop:reloop123@localhost:5432/reloop
REDIS_URL=redis://:reloop123@localhost:6379
PORT=8012
BASE_URL="https://local.reloop.sh"
NATS_URL=nats://localhost:4222
NODE_ENV=development
Reference Table
| Variable | Required | Default |
|---|---|---|
PG_URL | YES | postgresql://... |
REDIS_URL | YES | redis://... |
PORT | YES | 8012 |
BASE_URL | YES | https://local.reloop.sh |
NATS_URL | YES | nats://localhost:4222 |
Development Commands
| Command | Description |
|---|---|
bun be:api-key:dev | Start dev server with hot reloading |
bun run --filter=api-key build | Compile production bundle |
bun run --filter=api-key start | Run compiled production build |
bun run --filter=api-key check-types | TypeScript type-check |
Architecture
| Layer | Detail |
|---|---|
| Auth | @better-auth/api-key handles SHA-256 hashing and key formatting. |
| Caching | Validated keys are cached in Redis for fast lookups. |
| Events | Key lifecycle events published to NATS under api-key.*. |
| Schema | apikey table in packages/db/src/schema/api-key.ts. |
Was this page helpful?