This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
A Cloudflare Workers Scheduled Worker that fetches exchange rates from Open Exchange Rates API and updates a Notion database hourly.
npm run dev # Start local dev server with scheduled trigger testing
npm run deploy # Deploy to Cloudflare Workers
npm run cf-typegen # Regenerate TypeScript types after changing bindings
After npm run dev, test the cron handler:
curl "http://localhost:8787/__scheduled?cron=0+*+*+*+*"
Or use the manual sync endpoint:
curl "http://localhost:8787/sync"
src/index.ts - exports an ExportedHandler<Env> with fetch and scheduled handlerswrangler.jsonc - defines cron triggers and compatibility flagsworker-configuration.d.ts and src/env.d.tsHourly at minute 0 (0 * * * *).
| Endpoint | Description |
|---|---|
/sync |
Manually trigger exchange rate sync (returns JSON result) |
/ |
Info page |
Set via wrangler secret put <NAME> or .dev.vars for local development:
| Variable | Description |
|---|---|
OXR_APP_ID |
Open Exchange Rates API App ID |
NOTION_TOKEN |
Notion Integration Token |
NOTION_DATABASE_ID |
Notion Database ID |
| Property | Type | Description |
|---|---|---|
Code |
Title | Currency code (e.g., USD, EUR, CNY) |
Rate |
Number | Exchange rate against USD |
Updated At |
Date | Last update timestamp |
The nodejs_compat flag is enabled, allowing use of Node.js runtime APIs in the worker.
See AGENTS.md for Cloudflare Workers documentation links and error handling guidance.