CloudflarePlugin(options: CloudflarePluginOptions): IPlugin
Creates the Cloudflare Workers plugin.
The Worker's env is passed in rather than imported, because
cloudflare:workers is not a specifier any other runtime can resolve. The
plugin captures the bindings at register() and never calls a method on one
there: Cloudflare prohibits I/O outside a request context, so a probe read at
startup would throw on a real deployment while passing against every fake.
Example 1
Example 1
import { env, waitUntil } from 'cloudflare:workers'; import { CloudflarePlugin } from '@setu-ts/cloudflare-plugin'; const app = createApplication({ plugins: [ RuntimePlugin({ env }), CloudflarePlugin({ env, waitUntil, cache: { binding: 'CACHE_KV', prefix: 'cache:' }, }), ], }); export default { fetch: app.fetch };
options: CloudflarePluginOptions
The Worker env plus the capabilities to serve from it