Cloudflare Workers
此内容尚不支持你的语言。
Product Factory’s backend services are deployed as Cloudflare Workers using Wrangler.
Worker List
| Worker | Service Name | Purpose |
|---|---|---|
worker-gateway | gateway | API gateway and request routing |
worker-auth | auth | Authentication and user management |
worker-billing | billing | Credits, orders, subscriptions |
worker-ai | ai | AI provider management and completions |
worker-content | content | Blog, banners, friend links |
worker-support | support | Support tickets |
worker-admin | admin | Project and admin management |
Deployment
Deploy a single worker:
pnpm --filter worker-gateway wrangler deployDeploy all workers:
for worker in gateway auth billing ai content support admin; do pnpm --filter worker-$worker wrangler deploydoneWrangler Configuration
Each worker has a wrangler.toml in its app directory. Key configuration:
name = "gateway"main = "src/index.ts"compatibility_date = "2024-01-01"
[[services]]binding = "AUTH_SERVICE"service = "auth"Service Bindings
Workers communicate via service bindings (zero-latency RPC). The gateway binds to all downstream workers:
| Binding | Service |
|---|---|
AUTH_SERVICE | auth |
BILLING_SERVICE | billing |
AI_SERVICE | ai |
CONTENT_SERVICE | content |
SUPPORT_SERVICE | support |
ADMIN_SERVICE | admin |
Cron Triggers
Some workers use Cloudflare Cron Triggers for scheduled tasks:
| Worker | Schedule | Task |
|---|---|---|
worker-billing | Daily | Process expired subscriptions |
worker-auth | Daily | Clean expired sessions |
worker-billing | Hourly | Mark stale pending orders as failed |