瀏覽代碼

docs: update CLAUDE.md with convert endpoint and data flow

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
kotoyuuko 3 天之前
父節點
當前提交
b73ff1ab18
共有 1 個文件被更改,包括 14 次插入6 次删除
  1. 14 6
      CLAUDE.md

+ 14 - 6
CLAUDE.md

@@ -4,7 +4,7 @@ This file provides guidance to Claude Code (claude.ai/code) when working with co
 
 ## Project Overview
 
-A Cloudflare Workers **Scheduled Worker** that fetches exchange rates from Open Exchange Rates API and updates a Notion database hourly.
+A Cloudflare Workers **Scheduled Worker** that fetches exchange rates from Open Exchange Rates API and updates a Notion database hourly. Also provides a currency conversion API.
 
 ## Commands
 
@@ -16,14 +16,16 @@ npm run cf-typegen   # Regenerate TypeScript types after changing bindings
 
 ### Testing Locally
 
-After `npm run dev`, test the cron handler:
+After `npm run dev`:
 ```bash
+# Test scheduled handler
 curl "http://localhost:8787/__scheduled?cron=0+*+*+*+*"
-```
 
-Or use the manual sync endpoint:
-```bash
+# Manual sync
 curl "http://localhost:8787/sync"
+
+# Currency conversion
+curl "http://localhost:8787/convert?from=USD&to=CNY&amount=100"
 ```
 
 ## Architecture
@@ -40,7 +42,8 @@ Hourly at minute 0 (`0 * * * *`).
 
 | Endpoint | Description |
 |----------|-------------|
-| `/sync` | Manually trigger exchange rate sync (returns JSON result) |
+| `/convert?from=USD&to=CNY&amount=100` | Convert currency (data from Notion database) |
+| `/sync` | Manually trigger exchange rate sync from OXR to Notion |
 | `/` | Info page |
 
 ### Environment Variables (Secrets)
@@ -61,6 +64,11 @@ Set via `wrangler secret put <NAME>` or `.dev.vars` for local development:
 | `Rate` | Number | Exchange rate against USD |
 | `Updated At` | Date | Last update timestamp |
 
+### Data Flow
+
+1. **Sync** (hourly or manual): Fetch rates from OXR API → Update Notion database
+2. **Convert**: Read rates from Notion database → Calculate conversion
+
 ## Node.js Compatibility
 
 The `nodejs_compat` flag is enabled, allowing use of Node.js runtime APIs in the worker.