HTTP adapter
Mount unbound REST and viewer WebSocket routes in a host Elysia app.
createSacnHttpAdapter returns an Elysia plugin. It does not listen on a
port, configure CORS, rate-limit, or choose an auth policy. Your host app owns
deployment.
npm install @helioslx/core elysia @elysiajs/node @elysiajs/openapiimport { createSacnSource } from "@helioslx/core/node";
import { createSacnHttpAdapter } from "@helioslx/core/http";
import { Elysia } from "elysia";
const source = createSacnSource({
name: "HTTP control",
transportOptions: { iface: "192.168.10.20" },
installProcessHandlers: false,
});
await source.start();
const sacn = createSacnHttpAdapter({
source,
prefix: "/sacn",
auth: ({ request }) => {
// Return false for 401, or a Response to forward.
return request.headers.get("authorization") === `Bearer ${process.env.TOKEN}`;
},
});
const app = new Elysia().use(sacn);
app.listen({ hostname: "127.0.0.1", port: 3000 });Options
| Option | Default | Purpose |
|---|---|---|
source | required | Source to control |
viewer | — | Enables viewer routes and /viewer/ws |
prefix | /sacn | Route prefix |
auth | — | Hook per request |
openapiPath | /openapi | OpenAPI document path |
maxWebSocketClients | 64 | Concurrent viewer sockets |
webSocketQueueCapacity | 32 | Coalesced queue per socket |
Canonical routes
All paths are under prefix (default /sacn).
| Method | Path | Action |
|---|---|---|
GET | /health/live | Liveness |
GET | /health/ready | Ready when source is running |
GET | /universes | List active outputs |
GET | /engine/telemetry | Engine telemetry |
GET | /universes/:u/priorities/:p | Get one output |
PUT | /universes/:u/priorities/:p | Upsert full frame |
POST | /universes/:u/priorities/:p/channels | Sparse channel writes |
POST | /universes/:u/priorities/:p/frame | Write full frame |
DELETE | /universes/:u/priorities/:p | Clear output |
Channel bodies accept a map or an array of writes, with optional shared or
per-channel durationMs. Frame bodies use durationMs for a shared fade.
When a viewer is provided:
| Method | Path | Action |
|---|---|---|
GET/PUT/DELETE | /viewer/universes | Selection |
POST/DELETE | /viewer/universes/:universe | Add / remove |
GET | /viewer/telemetry | Viewer telemetry |
WS | /viewer/ws | Server → client packet stream |
Deprecated /outputs… aliases still exist with deprecation headers. Prefer the
/universes/…/priorities/… paths.
Host responsibilities
- Bind address (prefer
127.0.0.1unless auth and network are locked down) - TLS or reverse proxy
- CORS (avoid wildcards on live control)
- Rate and body-size limits
- Process signals and shutdown order when not using Node auto-handlers
The adapter owns neither the source nor the viewer. Stop the HTTP server, then
close() services you own.
See the embedded HTTP example.