Worker structure and patterns
export default { async fetch(request: Request, env: Env): Promise<Response> { const url = new URL(request.url) const path = url.pathname if (path.startsWith('/api/')) { return handleApiRequest(request, env) } return handleStaticAssets(request, env) } }
interface Env { DB: D1Database IMAGES: R2Bucket JWT_SECRET: string PRESENCE: DurableObjectNamespace }
On this page