跳转到内容

Cloudflare Workers

此内容尚不支持你的语言。

Product Factory’s backend services are deployed as Cloudflare Workers using Wrangler.

Worker List

WorkerService NamePurpose
worker-gatewaygatewayAPI gateway and request routing
worker-authauthAuthentication and user management
worker-billingbillingCredits, orders, subscriptions
worker-aiaiAI provider management and completions
worker-contentcontentBlog, banners, friend links
worker-supportsupportSupport tickets
worker-adminadminProject and admin management

Deployment

Deploy a single worker:

Terminal window
pnpm --filter worker-gateway wrangler deploy

Deploy all workers:

Terminal window
for worker in gateway auth billing ai content support admin; do
pnpm --filter worker-$worker wrangler deploy
done

Wrangler 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:

BindingService
AUTH_SERVICEauth
BILLING_SERVICEbilling
AI_SERVICEai
CONTENT_SERVICEcontent
SUPPORT_SERVICEsupport
ADMIN_SERVICEadmin

Cron Triggers

Some workers use Cloudflare Cron Triggers for scheduled tasks:

WorkerScheduleTask
worker-billingDailyProcess expired subscriptions
worker-authDailyClean expired sessions
worker-billingHourlyMark stale pending orders as failed