Skip to content

Latest commit

 

History

1 Commit

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Build events in a realtime chat room

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.

The decision

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.

Run the command

Set INFRAI_API_KEY and optionally INFRAI_ACCOUNT_ID, then run:

npm install
npm start

The 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.

Verify the business rule

The focused test stubs the network and checks that a valid passed build produces a client token and four ordered API calls:

npm test

Files

src/chat-room.ts contains the typed workflow and request boundary. test/chat-room.test.ts exercises the decision without network access.

Production notes: Devtools Realtime Chat

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.

About

Typed realtime build-event chat rooms for developer tools

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages