Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 34 additions & 0 deletions .dev.vars.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# ─────────────────────────────────────────────────────────────────────────────
# Cloudflare Pages — local edge-runtime secrets
#
# cp .dev.vars.example .dev.vars
# npx wrangler pages dev dist
#
# `wrangler pages dev` does NOT read `.env` — only this file (`.dev.vars`,
# gitignored). These are the *runtime* values the Functions see; the VITE_*
# ones are baked into the bundle by `npm run build/`vite already.
#
# In production these live in the Cloudflare dashboard:
# Workers & Pages → gtwdchat → Settings → Environment variables
# ─────────────────────────────────────────────────────────────────────────────

# Optional: run the API without any credentials at all.
# Mock mode is a local-dev convenience and is ignored on any Cloudflare
# deployment, so it can stay in this file safely.
MOCK_SUPABASE=1
NODE_ENV=development

# Origin used for OAuth redirects and the CORS allowlist.
APP_URL=http://localhost:8788

# ── Real credentials (only needed to exercise the live integrations) ─────────
GEMINI_API_KEY=
FIREBASE_SERVICE_ACCOUNT=
LIVEKIT_API_KEY=
LIVEKIT_API_SECRET=
GITHUB_CLIENT_ID=
GITHUB_CLIENT_SECRET=
SUPABASE_SERVICE_ROLE_KEY=
VITE_SUPABASE_URL=
VITE_SUPABASE_ANON_KEY=
ALLOWED_ORIGINS=
62 changes: 51 additions & 11 deletions .env.example
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
# ─────────────────────────────────────────────────────────────────────────────
# GrixChat environment template
#
# cp .env.example .env
# cp .env.example .env # local development
#
# Everything prefixed VITE_ is inlined into the browser bundle — never put a
# real secret there.
# Production runs on **Cloudflare Pages** (https://grixchat.gothwadtech.com).
# Every variable below goes into the Pages project:
# Cloudflare dashboard → Workers & Pages → gtwdchat → Settings → Environment
# variables (add each one to **Production** and **Preview**)
#
# Everything prefixed VITE_ is inlined into the browser bundle at build time —
# never put a real secret there. Changing one requires a redeploy.
#
# 💡 You do not need any of this for local development. `npm run dev:mock`
# runs the full app against an in-memory mock with seeded data.
Expand All @@ -27,37 +32,72 @@ VITE_FIREBASE_VAPID_KEY=
VITE_FIREBASE_DATABASE_URL=

# ── LiveKit (client URL only; keys stay on the server) ───────────────────────
# OPTIONAL. Leave empty and calls still work: CallProvider falls back to a real
# peer-to-peer WebRTC session signalled over Supabase Realtime
# (src/features/call/services/WebRtcCallService.ts). Set both this and the
# LIVEKIT_API_KEY / LIVEKIT_API_SECRET below to route calls through an SFU
# instead — that is what group calls and large rooms will need.
VITE_LIVEKIT_URL=

# ── Server-only secrets ──────────────────────────────────────────────────────
# Never prefix these with VITE_.
# Never prefix these with VITE_. On Cloudflare these are Pages environment
# variables; the Functions read them per request (they are not inlined).
#
# ⚠️ These CANNOT be read from a local `.env` inside the edge Functions — only
# the Node dev server (`npm run dev`) loads `.env`. For `wrangler pages dev`
# put them in `.dev.vars` (gitignored).

# Gemini, for the /api/grix-ai proxy
GEMINI_API_KEY=

# FCM service account, for /api/send-notification.
# Paste the whole JSON object; literal \n sequences in private_key are healed
# automatically by server.ts.
# automatically.
FIREBASE_SERVICE_ACCOUNT=

# LiveKit token signing, for /api/livekit-token
# LiveKit token signing, for /api/livekit-token. OPTIONAL — see above.
LIVEKIT_API_KEY=
LIVEKIT_API_SECRET=

# GitHub OAuth, for /api/github/auth-url
GITHUB_CLIENT_ID=
GITHUB_CLIENT_SECRET=

# Server-side Supabase client (bypasses RLS — server only)
# Server-side Supabase client (bypasses RLS — server only).
# Needed for push fan-out and FCM token cleanup.
SUPABASE_SERVICE_ROLE_KEY=

# Base URL used to build OAuth redirects
# Canonical origin: OAuth redirect base and the first entry of the CORS /
# origin allowlist. https://grixchat.gothwadtech.com
APP_URL=

# Set to "production" to serve dist/ instead of the Vite dev middleware
# Extra browser origins allowed to call /api/* (comma-separated).
# Same-origin requests are always allowed, so this is only needed when the
# frontend and the API live on different hosts.
ALLOWED_ORIGINS=

# ── Runtime flags ────────────────────────────────────────────────────────────
# Node dev server only: "production" serves dist/ instead of Vite middleware.
# Not needed on Cloudflare — but if you want the diagnostic route
# `/api/github/debug` to 404 everywhere, set NODE_ENV=production in the Pages
# environment as well (it is already hidden on any Pages deployment).
NODE_ENV=

# Node dev server only (`npm run dev:mock`) — skips JWT verification for the
# in-memory mock. Ignored on Cloudflare: the edge has no mock database, so it
# always verifies.
MOCK_SUPABASE=

# Port for the Node dev server. Cloudflare ignores it.
PORT=

# Node version used by the Cloudflare Pages build (`22`). `wrangler@4` requires
# Node >= 22, and Cloudflare's build runs `npm ci`, so 22 keeps the toolchain
# consistent. Set it in the Pages environment variables rather than here.
NODE_VERSION=

# ── Optional ─────────────────────────────────────────────────────────────────
# Path prefix when deploying to a sub-path (e.g. GitHub Pages "/grixchat/").
# Leave empty or "/" for a root deploy.
# Path prefix for a sub-path deploy. Cloudflare Pages serves from the domain
# root, so leave this alone unless you deliberately deploy under a prefix.
# Cloudflare Pages serves from the domain root — leave empty.
VITE_BASE_URL=
71 changes: 71 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
# Continuous integration only — Cloudflare Pages builds and deploys the site
# itself from this repository (Workers & Pages → gtwdchat).
#
# This workflow exists to fail fast on a broken push: a type error, a failing
# test or a broken bundle, before Cloudflare picks the commit up.
#
# There is deliberately no deploy step here. Deploying from two places is how
# you end up shipping a stale bundle, and the GitHub Pages deploy that used to
# live in `deploy.yml` could never work anyway: the API only exists on
# Cloudflare (`functions/`), so a github.io build would have a dead backend.
name: CI

on:
push:
branches: [ "main" ]
pull_request:
workflow_dispatch:

permissions:
contents: read

concurrency:
group: "ci-${{ github.ref }}"
cancel-in-progress: true

jobs:
verify:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v7
with:
# Nothing here needs git history beyond the commit being tested.
fetch-depth: 1

- name: Set up Node
uses: actions/setup-node@v7
with:
# 22, not 20: `wrangler@4` requires Node >= 22 and exits non-zero on
# older runtimes. The app itself builds on 20 — this is for the
# Pages Functions bundle check below.
node-version: 22
cache: 'npm'

- name: Install dependencies
run: npm ci

# `vite build` does not typecheck, so without this an entire class of
# breakage ships silently.
- name: Typecheck
run: npm run lint

- name: Test
run: npm test

# Verifies the Pages Functions actually bundle for the Workers runtime
# (no Node built-ins, no accidental `nodejs_compat` dependency).
- name: Build Pages Functions
# `pages functions build` needs to find `functions/` and `wrangler.toml`,
# so it runs from the repo root. Fails on any Node-only import.
run: npx wrangler pages functions build --outdir .wrangler/functions-build

- name: Build client bundle
# Dummy values so this compiles the real Supabase-backed code path and
# skips the "credentials are missing" build warning. The artifact is
# never deployed — Cloudflare builds separately with the real values
# from the project's environment variables.
env:
VITE_SUPABASE_URL: https://example.supabase.co
VITE_SUPABASE_ANON_KEY: ci-placeholder-anon-key
run: npm run build
55 changes: 0 additions & 55 deletions .github/workflows/deploy.yml

This file was deleted.

6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,9 @@ dist/
# test / tooling caches
.vite/
*.tsbuildinfo

# Cloudflare: `wrangler pages dev` state, build output, and .dev.vars secrets
.wrangler/
.dev.vars
!.dev.vars.example

Loading
Loading