Files
token-circles/worker/wrangler.jsonc
T
KomediruzeckiandGitHub 7c1eb80334 chore(worker): wire prod config — real D1 id, apex origins, api route (#320)
Point env.prod at the created finance-manager D1 (c70c3562), set CORS_ORIGIN/APP_ORIGINS to the apex https://tokencircles.com (app runs at the apex, not app.), reuse the dev Google OAuth client, and uncomment the api.tokencircles.com route.

Prod D1 already migrated (0001-0018, 33 tables); JWT_SECRET + GOOGLE_CLIENT_SECRET set via wrangler secret.
2026-07-14 16:42:29 +02:00

106 lines
5.4 KiB
JSON

{
"$schema": "node_modules/wrangler/config-schema.json",
// Finance Manager API worker (Hono + D1 + R2). Two deploy environments — `dev`
// (dev.<domain>) and `prod` (app.<domain>) — plus local dev off the top-level bindings.
// Everything marked PLACEHOLDER must be filled before the matching deploy; local dev
// works with the placeholders as-is.
"name": "finance-manager-api",
"main": "src/index.ts",
"compatibility_date": "2026-06-26",
"compatibility_flags": ["nodejs_compat"],
"observability": { "enabled": true },
// The Cloudflare account that owns the Worker + D1 + R2. From `wrangler whoami`,
// or export CLOUDFLARE_ACCOUNT_ID instead of setting it here.
// "account_id": "PLACEHOLDER_ACCOUNT_ID",
// ── Top-level bindings = what `pnpm run dev` (LOCAL dev) uses ──────────────────
// `wrangler dev` runs against a LOCAL D1 + R2 (state under .wrangler/, keyed by the
// binding NAME), so the placeholder database_id is fine locally. Apply the schema once
// with `pnpm run d1:migrate:local`. The env.dev / env.prod blocks override these for
// the real deployments.
"d1_databases": [{ "binding": "DB", "database_name": "finance-manager", "database_id": "local" }],
"r2_buckets": [{ "binding": "RECEIPTS", "bucket_name": "finance-manager-receipts" }],
"vars": {
"APP_ENV": "development",
"GOOGLE_CLIENT_ID": "PLACEHOLDER.apps.googleusercontent.com",
"CORS_ORIGIN": "http://localhost:3800",
// Public origin of THIS worker (email links must point here, not at the SPA host)
"API_PUBLIC_ORIGIN": "http://localhost:8787",
},
"env": {
// ── DEV → api.dev.<domain> (deploy: pnpm run deploy:dev) ──────────────────
"dev": {
"name": "finance-manager-api-dev",
// API on its own subdomain so the session cookie is same-site with the app
// (SameSite=Lax + COOKIE_DOMAIN). tokencircles.com must be an active zone in this
// Cloudflare account; `deploy:dev` then provisions the api.dev.tokencircles.com DNS.
"routes": [{ "pattern": "api.dev.tokencircles.com", "custom_domain": true }],
"vars": {
"APP_ENV": "dev",
"GOOGLE_CLIENT_ID": "961447002903-p2gkcujs85svbuf4tpmvu1cj4ge1ivh3.apps.googleusercontent.com",
"CORS_ORIGIN": "https://dev.tokencircles.com",
"APP_ORIGINS": "https://dev.tokencircles.com",
"API_PUBLIC_ORIGIN": "https://api.dev.tokencircles.com",
"COOKIE_DOMAIN": ".dev.tokencircles.com",
"EMAIL_FROM": "Token Circles <hello@tokencircles.com>",
// Stripe per-tier Price ids (TEST mode for dev) — vars, NOT secret. STRIPE_SECRET_KEY +
// STRIPE_WEBHOOK_SECRET are SECRETS (wrangler secret put). Steps: dotfiles billing-setup.md.
"STRIPE_PRICE_BASIC_MONTHLY": "price_1Tnn1kRczc8qAc4q8GsNyKQp",
"STRIPE_PRICE_BASIC_ANNUAL": "price_1TnnKVRczc8qAc4qEaqRAIwL",
"STRIPE_PRICE_ADVANCED_MONTHLY": "price_1Tnn9yRczc8qAc4qOjczMNxF",
"STRIPE_PRICE_ADVANCED_ANNUAL": "price_1TnnLCRczc8qAc4q0ISY361o",
"STRIPE_PRICE_ULTIMATE_MONTHLY": "price_1TnnB3Rczc8qAc4qN9rzHYIq",
"STRIPE_PRICE_ULTIMATE_ANNUAL": "price_1TnnI1Rczc8qAc4qzqUzzODg",
},
"d1_databases": [
{
"binding": "DB",
"database_name": "finance-manager-dev",
"database_id": "7a785adc-c378-43fa-b812-171319b81f22",
},
],
"r2_buckets": [{ "binding": "RECEIPTS", "bucket_name": "finance-manager-receipts-dev" }],
"triggers": {
// Budget alerts Mon 09:00 UTC; spending report twice monthly (1st + 15th) 10:00 UTC.
// NB: cron day-of-month and day-of-week are OR'd, so the old "1-7,15-21 * 4" fired on every
// day in those ranges AND every Thursday. Day-of-week is now "*" and the report is idempotent
// per half-month period (reminder_dedup), so a re-fire can't double-send.
"crons": ["0 9 * * 1", "0 10 1,15 * *"],
},
},
// ── PROD → api.<domain> (deploy: pnpm run deploy:prod) ────────────────────
"prod": {
"name": "finance-manager-api",
"routes": [{ "pattern": "api.tokencircles.com", "custom_domain": true }],
"vars": {
"APP_ENV": "production",
// Reuses the dev Google OAuth client. The prod redirect URI
// (https://api.tokencircles.com/api/auth/google/callback) and JS origin
// (https://tokencircles.com) must be added to this client in the Google console,
// or swap in a dedicated prod client id.
"GOOGLE_CLIENT_ID": "961447002903-p2gkcujs85svbuf4tpmvu1cj4ge1ivh3.apps.googleusercontent.com",
// App lives at the APEX (not app.<domain>): the SPA origin is the bare apex.
"CORS_ORIGIN": "https://tokencircles.com",
"APP_ORIGINS": "https://tokencircles.com",
"API_PUBLIC_ORIGIN": "https://api.tokencircles.com",
"COOKIE_DOMAIN": ".tokencircles.com",
},
"d1_databases": [
{
"binding": "DB",
"database_name": "finance-manager",
"database_id": "c70c3562-c081-4734-824c-9605537effda",
},
],
"r2_buckets": [{ "binding": "RECEIPTS", "bucket_name": "finance-manager-receipts" }],
},
},
// Secrets (NEVER in vars/here): JWT_SECRET, GOOGLE_CLIENT_SECRET.
// Set per env: pnpm run secret:dev / pnpm run secret:prod
// Locally they live in .dev.vars (see .dev.vars.example).
}