name = "weaveledger-api" main = "src/index.ts" compatibility_date = "2025-01-01" # Uncomment and set your custom domain after deployment: # routes = [ # { pattern = "ledger.yourdomain.com", custom_domain = true } # ] # D1 Database — create with: npx wrangler d1 create weaveledger-db [[d1_databases]] binding = "DB" database_name = "weaveledger-db" database_id = "" # Set after running: npx wrangler d1 create weaveledger-db migrations_dir = "migrations" # R2 Bucket — create with: npx wrangler r2 bucket create weaveledger-receipts [[r2_buckets]] binding = "RECEIPTS_BUCKET" bucket_name = "weaveledger-receipts" # Workflows [[workflows]] name = "receipt-processor" binding = "RECEIPT_WORKFLOW" class_name = "ReceiptProcessorWorkflow" # Inbound email routing (optional) # Configure in Cloudflare Dashboard > your domain > Email > Email Routing # to route receipts@yourdomain.com > this Worker # [[email_routing]] # enabled = true # Outbound email (optional) # [[send_email]] # name = "SEND_EMAIL" # Subscription enforcement — the iOS app requires a Pro subscription for full features. # The licensing worker validates subscriptions centrally. [vars] SUBSCRIPTION_ENFORCEMENT = "none" # Who may create accounts on your instance: # "open" — anyone who can reach the URL can register # "first_user" — registration closes once any account exists (default here: # register your own account right after deploying, then the # door closes; open registration would let strangers consume # your D1/R2 quota and your server-level AI key) # "invite" — new emails must hold a pending book invitation REGISTRATION = "first_user" # LICENSING_URL = "https://licensing.weavehub.app" # Only needed when SUBSCRIPTION_ENFORCEMENT = "licensing" # APPLE_BUNDLE_ID = "com.yourcompany.yourapp" # Optional: restrict Apple IAP verification to a specific bundle ID # ALLOWED_ORIGIN = "https://your-frontend.example.com" # Optional: override default CORS origin for a custom web frontend # APP_URL = "https://your-frontend.example.com" # Optional: base URL used in password reset emails (same as ALLOWED_ORIGIN if using a custom web frontend) # Environment variables (set via wrangler secret put) # Required: # npx wrangler secret put JWT_SECRET # # For AI receipt scanning (at least one required): # npx wrangler secret put CLAUDE_API_KEY # npx wrangler secret put OPENAI_API_KEY # # For Google Play webhooks (optional): # npx wrangler secret put GOOGLE_PLAY_WEBHOOK_SECRET # Cron triggers: # "0 6 * * *" — daily full sync (integrations, recurring expenses, # Apple finance-reports scan, auto-mark overdue # predicted payouts) # "*/10 * * * *" — every 10 min: stuck-receipt cleanup safety net # "0 7 1 * *" — monthly reconciliation: settle prior month + create # predicted payouts [triggers] crons = ["0 6 * * *", "*/10 * * * *", "0 7 1 * *"] # Upload size limit for receipt images (10 MB) [limits] cpu_ms = 30000 # --- Hosted AI (optional) ----------------------------------------------- # No Anthropic/OpenAI key? Use WeaveHub AI: metered, pay-as-you-go receipt # extraction hosted by WeaveHub. Get a key at https://weavehub.app/ai, then # uncomment the line below and set the key as your CLAUDE_API_KEY secret: # npx wrangler secret put CLAUDE_API_KEY (paste the wh_ai_... key) # ANTHROPIC_BASE_URL = "https://ai.weavehub.app"