Skip to content

Tier-2 - #7

Merged
Hum2a merged 19 commits into
tier-1from
tier-2
Jul 3, 2026
Merged

Tier-2#7
Hum2a merged 19 commits into
tier-1from
tier-2

Conversation

@Hum2a

@Hum2a Hum2a commented Jul 3, 2026

Copy link
Copy Markdown
Owner

Summary by cubic

Adds JWT auth and API key management, KV-cached session lists, and DO-based rate limiting to harden the API. The SPA gets media upload, polished page-load motion with skeletons, required field tooltips, game guides, PWA offline read-only, i18n, and scorecard export.

  • New Features

    • Auth & keys: POST /auth/token (exchange API key → short‑lived JWT); SPA AuthProvider + owner switcher; API key UI at /settings/keys; OpenAPI updated with BearerJwt.
    • Scale & reliability: RateLimiter Durable Object (per‑IP), KV cache for GET /sessions (HTTP max‑age 15s; KV 60s; X-Cache), structured JSON logs with X-Trace-Id, deep readiness GET /health?deep=1.
    • Media: /media/upload to R2 with progress/cancel (MediaUpload); PATCH supports videoUrl, videoPoster, hlsUrl, and player photos; added HLS MIME types.
    • Motion & UX: route transitions via AnimatedOutlet, destination‑aware skeletons, sliding TabStrip; required tooltips via TextField/SelectField/FileField; single‑source game guides (game-guides.ts) shown with GameGuideCard.
    • Extras: PWA with query persistence and offline banner; i18n via react-i18next (en); scorecard export to print‑ready HTML; static API docs served from /openapi.json and /docs/.
  • Migration

    • Set OCHE_JWT_SECRET in API env and sync dev vars (npm run setup:dev-vars:sync); optionally set VITE_PLAUSIBLE_DOMAIN or VITE_CF_WEB_ANALYTICS_TOKEN.
    • From apps/api: create KV namespace for CACHE and add IDs to wrangler.toml; apply the RateLimiter DO migration (tag v2) and redeploy.
    • Rebuild the SPA to pick up PWA/i18n and new routes; no breaking changes to existing endpoints.

Written for commit a7f441e. Summary will update on new commits.

Review in cubic

Hum2a and others added 19 commits July 3, 2026 12:57
- Added MediaUpload component for handling video and photo uploads with progress tracking and cancellation.
- Introduced SessionMediaSection for attaching media to sessions, including video and poster uploads.
- Enhanced CreateSession route to support optional player photo uploads during session creation.
- Updated SessionDetail to display video and media upload options.
- Improved media handling in the API, allowing for video URLs, posters, and player photos to be updated in sessions.
- Added support for new video MIME types and updated OpenAPI specifications accordingly.
- Implemented responsive image handling for session posters using PosterThumb component.
- Introduced a motion system with new utility classes for smooth transitions and animations.
- Updated various components (e.g., App, MediaUpload, SessionDetail) to utilize the new motion classes for improved user experience.
- Added AnimatedScore component for odometer-style score display using @number-flow/react.
- Implemented AnimatedOutlet and AnimatedPanel for route transitions with horizontal sliding effects.
- Enhanced accessibility by ensuring animations respect user preferences for reduced motion.
- Updated styling rules to maintain a cohesive visual identity with Tailwind and shadcn.
- Added new TabStrip component for improved navigation with sliding indicators.
- Introduced RouteSkeleton for better loading states that match destination layouts.
- Introduced a new `GameGuideCard` component to display game mode instructions in a collapsible format.
- Created a centralized `game-guides.ts` file as the single source of truth for game rules and instructions.
- Added a new `GAME-GUIDES.md` documentation file detailing how to play each game mode.
- Updated the `CreateSession`, `Overview`, and `SessionDetail` routes to incorporate the `GameGuideCard` for enhanced user experience.
- Implemented tests for the `resolveGameId` function to ensure accurate game mode detection from session titles.
- Enhanced documentation to guide future updates and maintain consistency across game instructions.
- Added support for JWT authentication, allowing users to exchange API keys for JWTs via the new `/auth/token` endpoint.
- Introduced API key management with routes for listing and creating API keys, enhancing security and user control.
- Updated the OpenAPI specification to reflect new authentication methods and security schemes.
- Enhanced the principal resolution logic to support JWTs and API keys, improving authorization handling across the application.
- Added tests to ensure proper functionality of the new authentication features and their integration with existing components.
…ures

- Introduced `RateLimiter` Durable Object for per-IP rate limiting, replacing in-memory token buckets.
- Added KV caching for session lists with a 15s TTL, including cache invalidation on session updates.
- Implemented structured JSON logging with `X-Trace-Id` for enhanced observability and error tracking.
- Updated health check endpoint to support deep readiness checks with database connectivity verification.
- Enhanced API routes and middleware to integrate new features, ensuring compliance with updated specifications.
- Added tests for health checks, rate limiting, and session caching functionalities to ensure reliability.
…ken setup

- Clarified the process for creating KV namespaces, specifying that commands should be run from the `apps/api` directory.
- Added instructions for copying KV namespace IDs into `wrangler.toml` for staging and production environments.
- Included guidance for local development without Cloudflare KV and troubleshooting authentication errors related to the Cloudflare API token.
- Added unit tests for the History and Overview components using Vitest and Testing Library, improving test coverage and reliability.
- Introduced contract tests to ensure OpenAPI paths align with expected schemas, enhancing API stability.
- Implemented visual regression tests with Playwright to capture UI changes and maintain visual consistency.
- Updated README and ROADMAP to reflect new testing capabilities and deployment instructions, including a full staging pipeline command.
- Upgraded Wrangler to version 4 across the project for improved development experience.
- Updated session list caching to use a 60s TTL in Cloudflare KV with a 15s HTTP max-age for responses, improving cache efficiency.
- Introduced a new utility function `isSessionId` for validating session IDs against a UUID format.
- Enhanced session retrieval routes to validate session IDs before processing requests, ensuring better error handling.
- Refactored cache-related functions to handle errors gracefully, maintaining API reliability.
- Updated documentation to reflect changes in caching strategy and session ID validation.
- Integrated PWA capabilities using vite-plugin-pwa, enabling offline access and caching for session data.
- Added i18n support with react-i18next, providing English translations for navigation and session details.
- Implemented a scorecard export feature, allowing users to generate print-ready scorecards for sessions.
- Introduced an OfflineBanner component to notify users when offline, enhancing user experience.
- Updated package dependencies to include necessary libraries for analytics and query persistence.
- Enhanced documentation to reflect new features and usage instructions.
… updates

- Updated the `FileField` component to include a visible button for file selection, improving user experience.
- Implemented state management to display the selected file name, enhancing feedback for users.
- Modified tooltip descriptions in the documentation to clarify the new file input pattern and usage guidelines.
- Ensured accessibility by maintaining proper aria attributes and labels for the file input.
@Hum2a
Hum2a merged commit 47414b0 into tier-1 Jul 3, 2026
1 check failed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant