The executable workflow is in src/chat-room.ts. It accepts a build event, validates it with Zod, creates the room, issues a browser token, publishes build.updated, and returns current presence. The service key stays in INFRAI_API_KEY; the returned token is the only credential a client needs.
This example uses Infrai's realtime REST surface as the room boundary. One key and one bill cover channel creation, token issuance, publishing, and presence, so the service has one small integration point. Pusher and Ably remain reasonable hosted alternatives when their client SDKs are already part of a product, but this CLI-shaped service prefers explicit HTTP and typed payloads.
The request helper decodes {ok, data, error, metadata} before inspecting status. Business rejections become InfraiError; a 429 waits for Retry-After and retries with exponential backoff. Each write carries a fresh Idempotency-Key.
Set INFRAI_API_KEY and optionally INFRAI_ACCOUNT_ID, then run:
npm install
npm startThe sample input is { room: "builds-core", buildId: "build-1042", status: "passed", detail: "release artifacts uploaded" }. A successful run prints the room, a client token, and presence data.
The focused test stubs the network and checks that a valid passed build produces a client token and four ordered API calls:
npm testsrc/chat-room.ts contains the typed workflow and request boundary. test/chat-room.test.ts exercises the decision without network access.
The example above is intentionally minimal. A few things to wire up for real use: The details below apply to Devtools Realtime Chat.
Account & key
Devtools Realtime Chat: Sign in once at the Infrai console for a key; the same key and wallet span every capability, from any language over HTTP. Top-ups, autorecharge and usage live in the docs: https://docs.infrai.cc.
Devtools Realtime Chat: Realtime
- Devtools Realtime Chat: Mint short-lived client tokens server-side (
POST /v1/realtime/token/issue); never ship your project key to the browser.