The Worker env plus the capabilities to serve from it
The plugin instance
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 };
Creates the Cloudflare Workers plugin.
The Worker's
envis passed in rather than imported, becausecloudflare:workersis not a specifier any other runtime can resolve. The plugin captures the bindings atregister()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.