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.

PropertyValue
Directoryapps/backend/api-key
Port8012
Local URLhttps://local.reloop.sh/api/api-key
Swagger UIhttps://local.reloop.sh/api/api-key/openapi
StackElysiaJS 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

VariableRequiredDefault
PG_URLYESpostgresql://...
REDIS_URLYESredis://...
PORTYES8012
BASE_URLYEShttps://local.reloop.sh
NATS_URLYESnats://localhost:4222

Development Commands

CommandDescription
bun be:api-key:devStart dev server with hot reloading
bun run --filter=api-key buildCompile production bundle
bun run --filter=api-key startRun compiled production build
bun run --filter=api-key check-typesTypeScript type-check

Architecture

LayerDetail
Auth@better-auth/api-key handles SHA-256 hashing and key formatting.
CachingValidated keys are cached in Redis for fast lookups.
EventsKey lifecycle events published to NATS under api-key.*.
Schemaapikey table in packages/db/src/schema/api-key.ts.

Was this page helpful?

Edit this page