function createScheduledHandler
Since 0.2.0
createScheduledHandler(cron: WorkersCron): ScheduledHandler

Builds the handler an application exports as scheduled.

Takes the WorkersCron directly rather than the application, unlike createQueueHandler. That asymmetry follows from a decision rather than an oversight: WorkersCron deliberately does not claim CAPABILITIES.SCHEDULER (see its module doc), so it is not in the registry to resolve — and it needs neither an id source nor a clock, so the application can construct it directly.

Examples

Example 1

const cron = new WorkersCron({ logger });
cron.on('*\/5 * * * *', () => sweepExpiredSessions(app));

export default { fetch: app.fetch, scheduled: createScheduledHandler(cron) };

Parameters

The registry carrying the handlers

Return Type

The handler to assign to the Worker's scheduled export

Usage

import { createScheduledHandler } from "cloudflare-plugin/src/index.ts";