Surplus logo
Surplus Docsby Sharing Excess
GuidesDevelopersApps and services

API server (apps/server)

The server is a Hono application that exposes:

  • ORPC procedures (typed RPC) mounted for the web client
  • /openapi.json — OpenAPI document generated from the ORPC router
  • /openapi — Scalar UI for exploring the HTTP mapping
  • Auth — email OTP and long-lived HTTP-only cookies (see docs/architecture.md)

Structure

  • src/helpers/orpc.ts — central ORPC router wiring and handler registration
  • src/routes/** — per-domain route modules co-located with handlers
  • src/helpers/env.ts — Zod-validated environment for this process

Running locally

From the repo root (or apps/server):

cd apps/server
bun run dev

The default dev port is 8080 (see apps/server/package.json).

Services

Domain logic lives in packages/services. The server constructs services with real db, redis, and storage clients and passes them into ORPC context—services never read process.env directly.