Shane
Shane
CDCloudflare Developers
Created by Web Bae on 10/5/2024 in #workers-help
Fetch inside a scheduled Cron Job
Right now your code has the scheduled job and the API in the same worker. Is that what you want? I never done it, but you should be able to ping the API handler from the scheduled job using the Worker URL & fetch (maybe there's another way, IDK). You'd want your Worker to look like this:
import { Hono } from 'hono'

type Bindings = {
//
}

const app = new Hono<{Bindings: Bindings}>()

// Routes

export default {
fetch: app.fetch,
scheduled: async (event: ScheduledEvent, env: Bindings) => {
//
}
}
import { Hono } from 'hono'

type Bindings = {
//
}

const app = new Hono<{Bindings: Bindings}>()

// Routes

export default {
fetch: app.fetch,
scheduled: async (event: ScheduledEvent, env: Bindings) => {
//
}
}
Source: https://hono.dev/docs/getting-started/cloudflare-workers#using-hono-with-other-event-handlers You can also do this with two Workers. The concept would be the same (scheduled job sends a fetch request to the API Worker URL). I'm about to log off, but I think this will put you in the right direction.
4 replies
CDCloudflare Developers
Created by Shane on 10/4/2024 in #workers-help
Worker API inconsistency
No description
7 replies
CDCloudflare Developers
Created by Shane on 10/4/2024 in #workers-help
Worker API inconsistency
Account ID: 1b09090caf812db256cc6a9a00315d75 The version tests were done on worker: royal-feather-4e5a I realized "usage_model" was unnecessarily set. I removed it, but it made no difference. The reproduction repo now reflects that change.
7 replies