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

Add support to Cloudflare Worker scheduled event #164

Open
EricxStone opened this issue Aug 30, 2021 · 0 comments
Open

Add support to Cloudflare Worker scheduled event #164

EricxStone opened this issue Aug 30, 2021 · 0 comments

Comments

@EricxStone
Copy link

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")
})
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant