Base class for Cloudflare Durable Objects with built-in routing support.
This package provides a convenient base class that extends Cloudflare's DurableObject with automatic routing capabilities using @whi/cf-routing.
import { BaseDurableObject } from '@whi/cf-do-base';import { DurableObjectRouteHandler } from '@whi/cf-routing';class CounterHandler extends DurableObjectRouteHandler { async get() { const count = await this.ctx.storage.get('count') || 0; return { count }; }}export class Counter extends BaseDurableObject { constructor(ctx, env) { super(ctx, env, 'counter'); this.router.defineRouteHandler('/count', CounterHandler); }} Copy
import { BaseDurableObject } from '@whi/cf-do-base';import { DurableObjectRouteHandler } from '@whi/cf-routing';class CounterHandler extends DurableObjectRouteHandler { async get() { const count = await this.ctx.storage.get('count') || 0; return { count }; }}export class Counter extends BaseDurableObject { constructor(ctx, env) { super(ctx, env, 'counter'); this.router.defineRouteHandler('/count', CounterHandler); }}
Base class for Cloudflare Durable Objects with built-in routing support.
This package provides a convenient base class that extends Cloudflare's DurableObject with automatic routing capabilities using @whi/cf-routing.
Example