f4c-room-api v0.1.0
adapter
capsule://quake0day/[email protected]
Provides API endpoints for creating and joining chat rooms, issuing RealtimeKit participant tokens, and persisting room metadata in Cloudflare KV. It handles room type negotiation, expiry, and initial rate limiting.
Owns
- API endpoint for token generation and room creation
- Room metadata persistence in Cloudflare KV
- RealtimeKit meeting creation and participant token issuance
- IP-based rate limiting for token requests
- Turnstile token verification
Does not own
- Actual real-time communication
- Bot logic
- Frontend UI components
AI orientation
This capsule manages room lifecycle and authentication. Agents should focus on refining rate limiting, improving room expiry logic, or integrating with different real-time communication backends. Ensure security best practices for token generation and origin checks.
Avoid
- Embedding UI logic or specific frontend dependencies.
- Hardcoding RealtimeKit-specific values that could be parameterized.
Provides
http_api:/api/token— Endpoint to request an authentication token for a chat room, creating the room if it doesn't exist.
Requires
env:ROOMS_KV— Cloudflare KV Namespace for storing room metadata.env:CF_API_TOKEN— Cloudflare API token for interacting with RealtimeKit API.env:CF_ACCOUNT_ID— Cloudflare account ID for RealtimeKit API calls.env:RTK_APP_ID— RealtimeKit application ID.env:RTK_PRESET_NAME— Default RealtimeKit preset name for meetings.env:RTK_SCREENSHARE_PRESET_NAME— RealtimeKit preset name for screen share enabled meetings.env:RTK_AUDIO_PRESET_NAME— RealtimeKit preset name for audio-only meetings.env:TURNSTILE_SECRET_KEY— Secret key for Cloudflare Turnstile verification.http_api:Cloudflare RealtimeKit API— External API for creating meetings and participants.http_api:Cloudflare Turnstile API— External API for verifying Turnstile tokens.
Dependencies
Capsules
f4c-turnstile-gate>=0.1.0
Invariants (must always hold)
- Room records in KV must accurately reflect the current state (meetingId, roomType, botEnabled, createdAt).
- Rate limits must be enforced per IP.
- Turnstile tokens must be validated if `TURNSTILE_SECRET_KEY` is set.
Source files (1)
Click any file to view its content; the path on the right shows where the file lands when this capsule is installed.
src/app/src/pages/api/token.ts→api/token.ts
Plus capsule.yaml and
install.json.