Worker Entrypoint
The Worker entrypoint usually exports:
- a default
fetchhandler - each Durable Object class as a named export
Worker.make(...) supplies the Worker-side runtime for ordinary HTTP handling.
ActorNamespace provides the Worker-side Durable Object binding, while
ActorRuntime.make(...) defines the Durable Object class.
Build the entrypoint
export { as }
const = .(
.("GET", "/", .(.("ok"))),
.(
"GET",
"/play",
.(function* () {
const { , } = yield* .
return yield* .().({ })
}),
),
.({
: ["*"],
: ["*"],
: ["*"],
}),
.("*", "/*", .),
)
export default .({
: .(., .),
: .(
,
.,
.("ASSETS"),
),
})Things to notice
HttpRouter.add(method, path, effect)mounts a single route.HttpRouter.cors(...)wires up CORS for every route in the router.HttpRouter.add("*", "/*", Assets.forward)falls through to the Cloudflare Assets binding for unmatched requests.Worker.make({ handler, prelude })produces the Workerfetchexport.- The Durable Object runtime class must be re-exported from the Worker entrypoint under the binding's class name.