Extract the leaderboard into a generic, backend-agnostic package and add rolling Today/Week/Month/All-Time windows, a web component, and local-first development against the Firestore emulator. Package (leaderboard/): - LeaderBoardService: backend-agnostic core via a storage-adapter seam, with Firebase and Supabase adapters (Supabase client injected, no added dep) - Rolling time windows (last 24h / 7d / 30d) with hover tooltips; top-N by score - <cozy-leaderboard> web component built on web-component-base: compose the UI in HTML, configure the backend once in JS - Every user-facing string is configurable (labels, tooltips, empty/loading/ error messages, anonymous name) so i18n lives in the app; README + CONFIGURATION App (mnswpr.com): - Compose the board declaratively in index.html via <cozy-leaderboard> - Nickname + randomized greeting bar; score submission through the element - Legends: the current all-time leaders frozen into a static /legends page - Firebase config and leaderboard namespace via Vite env vars; emulator-first local dev (VITE_FIRESTORE_EMULATOR) Firebase schema-as-code: - firebase.json, .firebaserc, firestore.rules (public reads, create-only scores, no client updates/deletes, namespace-generalized), empty indexes (rolling windows need none) - prod (mw-*) vs dev/test (mw-test-*) separation by collection namespace - emulator config, seed script, and docs (firebase-leaderboards.md, leaderboard-env-migration.md, AYO.md) Utils/tests: UTC date-bucket helper (retained as metadata) with Vitest coverage.
23 lines
1.3 KiB
Text
23 lines
1.3 KiB
Text
# Development Firebase config (project: secure-moment-188701).
|
|
# These keys are public, not secrets — access is governed by firestore.rules —
|
|
# so this file is committed. Used by `pnpm dev`.
|
|
# Production values are supplied as Netlify env vars at build time (see
|
|
# docs/firebase-leaderboards.md); never put production values here.
|
|
VITE_FIREBASE_API_KEY=AIzaSyCTi_5Sm5dHFNf0d_Gn0MNWmlGheFBf6MQ
|
|
VITE_FIREBASE_AUTH_DOMAIN=moment-188701.firebaseapp.com
|
|
VITE_FIREBASE_DATABASE_URL=https://moment-188701.firebaseio.com
|
|
VITE_FIREBASE_PROJECT_ID=secure-moment-188701
|
|
VITE_FIREBASE_STORAGE_BUCKET=secure-moment-188701.firebasestorage.app
|
|
VITE_FIREBASE_MESSAGING_SENDER_ID=113827947104
|
|
VITE_FIREBASE_APP_ID=1:113827947104:web:b176f746d8358302c51905
|
|
VITE_FIREBASE_MEASUREMENT_ID=G-LZRDY0TG46
|
|
|
|
# Leaderboard collection namespace. Dev/test uses a separate set of collections
|
|
# (mw-test-scores / mw-test-all / mw-test-config) in the SAME Firebase project,
|
|
# so local play never pollutes the production board. Production sets this to `mw`.
|
|
VITE_LB_NAMESPACE=mw-test
|
|
|
|
# Local dev runs against the Firestore emulator by default (no cloud, no deploy).
|
|
# Start it with `pnpm emulators` and fill it via `pnpm seed:emulator`.
|
|
# To use the cloud `mw-test` namespace instead, set this empty in app/.env.local.
|
|
VITE_FIRESTORE_EMULATOR=1
|