Skip to content
This repository was archived by the owner on Jun 6, 2024. It is now read-only.
This repository was archived by the owner on Jun 6, 2024. It is now read-only.

Add support to Cloudflare Worker scheduled event #164

@EricxStone

Description

@EricxStone

Background

Cloudflare has added the support of their worker to be triggered by scheduled event. These workers are triggered on the cron schedule setup on Cloudflare Worker dashboard. They are implemented with an event listener to scheduled event instead of fetch in traditional worker. This causes the test with Cloudworker impossible.

Enhancement

Add the support of scheduled event to Cloudworker, where developers can mock the trigger of the worker. The usage of such worker will become

const Cloudworker = require('@ericxstone/cloudworker')

const simpleScript = `addEventListener('scheduled', event => {
  event.waitUntil(() => {});
})`

const cw = new Cloudworker(simpleScript)
cw.triggerCronJob.then((res) => {
  console.log("Schedule is triggered")
})

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions