E5 auto-renewal application ported to Cloudflare Workers platform.
- ✅ Generate Excel files in memory using SheetJS (
xlsx) - ✅ Store tokens using KV Storage (replaces .env file)
- ✅ Support for Cron Triggers for scheduled execution
- ✅ All API functionalities fully ported
npm install# Create KV namespace
wrangler kv namespace create "E5_CONFIG"
# Update the returned ID in `wrangler.jsonc` under `kv_namespaces[0].id`Use Cloudflare Secrets instead of plain env vars:
wrangler secret put CLIENT_ID # Azure Application ID
wrangler secret put CLIENT_SECRET # Azure Application Secret
wrangler secret put ADMIN_TOKEN # required to call the trigger endpoints
wrangler secret put TELEGRAM_BOT_TOKEN # optional
wrangler secret put CHAT_ID # optional
wrangler secret put TOPIC_ID # optional, forum topic (message_thread_id) in a supergroupNotes:
- Secrets are referenced in code via
c.env.VAR_NAME(e.g.c.env.CLIENT_ID). - For local development, you can use
wrangler secret putin dev too, or a.dev.varsfile (not committed) for convenience.
# Write initial refresh_token to KV
wrangler kv key put --namespace-id=YOUR_NAMESPACE_ID "MS_TOKEN" "YOUR_REFRESH_TOKEN" --remotenpm run deployAfter deployment, manually trigger via these endpoints. The POST endpoints require Authorization: Bearer <ADMIN_TOKEN> and return 401 if ADMIN_TOKEN is not set:
POST /update-token- Update tokenPOST /run-read- Execute read APIsPOST /run-write- Execute write APIsGET /status- Check whether tokens are present in KV
curl -X POST -H "Authorization: Bearer $ADMIN_TOKEN" https://<your-worker>.workers.dev/run-readConfigured schedule (UTC time):
- Token update: Monday, Thursday, Saturday at 10:10
- Read APIs: Every 6 hours on weekdays
- Write APIs: Daily at 23:12
- Uses xlsxwriter to generate Excel
- Stores token in .env file
- Uses crontab for scheduling
- Uses SheetJS (
xlsx) - Stores token in KV Storage
- Uses Cron Triggers
- Workers have 30-second execution time limit
- Cannot use time.sleep() delays
- All file operations performed in memory
View logs using Wrangler:
npm run tail