Packages
@fluxy-chat/config
Type-safe fluxy.config.ts authoring for FluxyChat: room authz, middleware, and client defaults.
@fluxy-chat/config
Type-safe fluxy.config.ts authoring for FluxyChat: room authz, middleware, and client defaults.
Install
pnpm add -D @fluxy-chat/configQuick start
Create fluxy.config.ts at your worker project root:
import { defineConfig, allow, block, defineMiddleware, allowPublish } from "@fluxy-chat/config";
const moderate = defineMiddleware("publish", (ctx) => {
if (!ctx.capabilities.publish) {
return { action: "block", reason: "You cannot post here." };
}
return allowPublish();
});
export default defineConfig({
client: {
readOn: "visible",
wsCache: "on",
historyLimit: 50,
},
rooms: {
"support-*": {
anonymous: false,
authz: (ctx) => (ctx.anonymous ? block("Sign in first.") : allow({ publish: true })),
onPublish: [moderate.handler],
},
"room-*": { anonymous: true, onPublish: [moderate.handler] },
},
});Wire it in the Worker (this repo: apps/worker/fluxy.config.js → bundled by Wrangler).
What you can configure
| Area | Typical hosted SDK | Fluxy field |
|---|---|---|
Room templates room-* | Channel patterns | rooms |
| Anonymous access | Guest connect | rooms.*.anonymous |
| Connect authz | Join rules | rooms.*.authz |
| Message middleware | Pre-send hooks | rooms.*.onPublish |
| Disconnect hooks | Cleanup | rooms.*.disconnect |
| SDK defaults | — | client (via GET /config/client) |
Client defaults
The worker exposes merged defaults:
GET /config/client
→ { client: { readOn, wsCache, historyLimit, ... }, source: "fluxy.config" }Use in your app to align useChat options with server policy.
Hosted overlay (pnpm fluxy:deploy)
One file on hosted: fluxy.hosted.json (or hostedPublish + serializable rooms on defineConfig). Push with PUT /admin/projects/:id/publish-config or pnpm fluxy:deploy.
Fields: denySubstrings, guestCanPublish, iotAutoAgentId, and rooms templates (anonymous, per-room deny, guestCanPublish, capabilities, extensions kv/counter slots). This is not Worker-bundled onPublish / authz callbacks. Those run only on a Worker you deploy.
Room snapshots: GET/PUT /rooms/:id/extensions/:extId (max 5, 16 KiB). Hosted ids must be declared on the overlay.
Self-hosted execution
Fluxy runs your config callbacks inside your Worker — you own execution and secrets (Wrangler vars / secrets).