HaloStack Docs
Open App
Apps

API

The Elysia HTTP API — a thin Bun runtime shell around the shared @halostack/elysia app.

apps/api is the HTTP API: an Elysia server running on the Bun runtime, listening on API_PORT (Railway's injected PORT in production, or 3000 by default). It is deliberately a thin shell. The application itself — its routes, OpenAPI surface, and the Eden client — all live in @halostack/elysia. This package's only job is to wire up runtime concerns such as observability, start listening, and drain cleanly on shutdown.

Stack

The runtime is composed from a handful of shared pieces:

  • Elysia, the Bun web framework, running on the Bun runtime.
  • @halostack/elysia — the shared app instance, which carries the routes, the auth mount, and OpenAPI.
  • @halostack/telemetry — OpenTelemetry traces, metrics, and logs, initialized via initObservability.
  • @halostack/env — validated configuration (API_PORT, API_HOST, and so on); never read process.env directly.

Structure

The package is just two files, each with a clear responsibility:

  • src/index.ts is the entry point. It boots observability, calls app.listen(), and registers SIGINT and SIGTERM handlers that flush telemetry before the process exits.
  • src/instrument.ts initializes Sentry. It is imported first in index.ts so that it wraps everything booted afterward, and it is a no-op unless SENTRY_ENABLED is set. The split of responsibilities is intentional: Sentry owns error grouping, while @halostack/telemetry (OpenTelemetry) owns traces, metrics, and logs.

Running

Conventions

Keep this package thin. Route logic does not belong here — add a feature module in @halostack/elysia (under packages/elysia/src/modules/*) instead, so the Eden client stays type-synced with the API. Read all configuration through @halostack/env. The interactive OpenAPI docs are served at /openapi.