nodefony-add-realtime-channel

Adds role-protected realtime channels to Nodefony applications using RealtimeController decorators.

Updated Dec 19, 2023
One-click install
npx skills add https://github.com/nodefony/nodefony-core --skill nodefony-add-realtime-channel-nodefony
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: nodefony-add-realtime-channel
Source: https://github.com/nodefony/nodefony-core/tree/main/src/packages/%40nodefony/devkit/skills/nodefony-add-realtime-channel
Command: npx skills add https://github.com/nodefony/nodefony-core --skill nodefony-add-realtime-channel-nodefony

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Adding WebSocket functionality to a Nodefony app by hand means losing routing by channel, shared HTTP authentication, and backpressure handling. This Skill guides you to add realtime streams through the framework's proper layer — a RealtimeController with channel decorators — and to close channels to specific roles instead of leaving them public by default. ## Core Features & Use Cases - Scaffold a realtime controller: Run npx nodefony create controller Ops --kind realtime to generate a RealtimeController subclass with a decorated channel and action, fully wired. - Channel and action authorization: Apply @RealtimeChannel and @RealtimeAction decorators with roles or authenticated policies, understanding that channel policy controls subscription while action policy controls invocation. - Avoid the dynamic channel name trap: Learn why channels with runtime-computed names (like room:${id}) are not covered by any declared policy and are born public. - Client-side subscription: Use RealtimeClient from nodefony/client (never the root nodefony import) to subscribe to channels in the browser, with React hooks available. - Use Case: You need to push live ops alerts only to administrators. Generate the controller, decorate the channel with { roles: ["ROLE_ADMIN"] }, subscribe from the client facade, and verify with three identities that anonymous and non-admin users receive nothing while the public scaffold channel still works. ## Quick Start Ask the AI to add a realtime channel named ops:alerts restricted to ROLE_ADMIN in your Nodefony application and show the client subscription code.

Frequently Asked Questions about nodefony-add-realtime-channel

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I add a WebSocket channel to a Nodefony application?

Run `npx nodefony create controller Ops --kind realtime` to scaffold a RealtimeController subclass with a decorated channel and action. Do not write raw `new WebSocket(...)` server code, since that bypasses channel routing, shared HTTP authentication, and backpressure.

How do I restrict a realtime channel to specific roles in Nodefony?

Decorate the channel with `@RealtimeChannel("ops:alerts", { roles: ["ROLE_ADMIN"] })` and actions with `@RealtimeAction` policies. Channel policy controls who can subscribe, while action policy controls who can trigger it; use `{ authenticated: true }` when no specific role is needed.

Why is my Nodefony realtime channel public even though I set a policy?

Policies are indexed by the exact channel name, so a channel whose name is computed at runtime (like `room:${id}`) is not covered by any declared policy and is born public. Only statically named channels are protected by declared policies.

Can I import RealtimeClient from the nodefony root package in the browser?

No, you must import `RealtimeClient` from `nodefony/client`. The root `nodefony` package does not expose these symbols in the browser, and the compiler will reject the import.

How do I verify a realtime channel is properly protected?

Run `npm test` and `npx nodefony inspect routes --json` to see mounted channels, then test with three identities: anonymous and non-role users must not receive the restricted stream, the admin must, and the public scaffold channel must still respond.