interface Options {
    orm?: { logger?: Logger; schema: DatabaseSchema };
    rateLimit?: WorkerKVRateLimit.Options;
    jobs(): Job<Data<Parser<unknown>>>[];
    onJobError(error: unknown, message: Message<unknown>): void;
    onQueue(
        batch: MessageBatch<unknown>,
        env: Environment,
        ctx: ExecutionContext,
    ): Promise<void>;
    onRequest(
        request: Request<unknown, CfProperties<unknown>>,
        env: Environment,
        ctx: ExecutionContext,
    ): Promise<Response>;
    onSchedule(
        event: ScheduledController,
        env: Environment,
        ctx: ExecutionContext,
    ): Promise<void>;
    onTaskError(error: unknown, task: Task): void;
    tasks(): Task[];
}

Properties

orm?: { logger?: Logger; schema: DatabaseSchema }

The options for the ORM.

Type declaration

  • Optionallogger?: Logger

    The logger for the ORM.

  • schema: DatabaseSchema

    The database schema for the ORM.

The options for the rate limit.

Methods

  • A function that returns the list of jobs to register

    Returns Job<Data<Parser<unknown>>>[]

  • A function that will run if a job failed

    Parameters

    • error: unknown
    • message: Message<unknown>

    Returns void

  • The function that will run every time a queue message is consumed

    Parameters

    • batch: MessageBatch<unknown>
    • env: Environment
    • ctx: ExecutionContext

    Returns Promise<void>

  • The function that will run every time a new request comes in

    Parameters

    • request: Request<unknown, CfProperties<unknown>>
    • env: Environment
    • ctx: ExecutionContext

    Returns Promise<Response>

  • The function that will run every time a scheduled task is executed

    Parameters

    • event: ScheduledController
    • env: Environment
    • ctx: ExecutionContext

    Returns Promise<void>

  • A function that will run if a task failed

    Parameters

    • error: unknown
    • task: Task

    Returns void