@astrojs/cloudflare@12.6.0
Minor Changes
-
#13837
7cef86f
Thanks @alexanderniebuhr! - Adds new configuration options to allow you to set a customworkerEntryPoint
for Cloudflare Workers. This is useful if you want to use features that require handlers (e.g. Durable Objects, Cloudflare Queues, Scheduled Invocations) not supported by the basic generic entry file.This feature is not supported when running the Astro dev server. However, you can run
astro build
followed by eitherwrangler deploy
(to deploy it) orwrangler dev
to preview it.The following example configures a custom entry file that registers a Durable Object and a queue handler:
// astro.config.ts import cloudflare from '@astrojs/cloudflare'; import { defineConfig } from 'astro/config'; export default defineConfig({ adapter: cloudflare({ workerEntryPoint: { path: 'src/worker.ts', namedExports: ['MyDurableObject'], }, }), });
// src/worker.ts import type { SSRManifest } from 'astro'; import { App } from 'astro/app'; import { handle } from '@astrojs/cloudflare/handler'; import { DurableObject } from 'cloudflare:workers'; class MyDurableObject extends DurableObject<Env> { constructor(ctx: DurableObjectState, env: Env) { super(ctx, env); } } export function createExports(manifest: SSRManifest) { const app = new App(manifest); return { default: { async fetch(request, env, ctx) { await env.MY_QUEUE.send('log'); return handle(manifest, app, request, env, ctx); }, async queue(batch, _env) { let messages = JSON.stringify(batch.messages); console.log(`consumed from our queue: ${messages}`); }, } satisfies ExportedHandler<Env>, MyDurableObject, }; }
Patch Changes
-
#13963
c667c55
Thanks @florian-lefebvre! - Fixes a case where the platform proxy would not be disposed when the dev process ended -
Updated dependencies []:
- @astrojs/underscore-redirects@1.0.0