mirror of
https://github.com/michivonah/themepark-assistant.git
synced 2025-12-22 22:16:29 +01:00
implement cron router + install cloudflare types
This commit is contained in:
parent
dfadc64afa
commit
3f9547f014
5 changed files with 7509 additions and 1 deletions
|
|
@ -2,6 +2,7 @@ import { Hono } from 'hono'
|
|||
import { bearerAuth } from 'hono/bearer-auth'
|
||||
import notification from './notification'
|
||||
import logbook from './logbook'
|
||||
import cronRouter from './jobs/cron'
|
||||
|
||||
// create app
|
||||
const app = new Hono()
|
||||
|
|
@ -14,4 +15,7 @@ app.use('/*', bearerAuth({ token }))
|
|||
// define routes & export app
|
||||
app.route('/notification', notification)
|
||||
app.route('/logbook', logbook)
|
||||
export default app
|
||||
export default {
|
||||
fetch: app.fetch,
|
||||
scheduled: cronRouter,
|
||||
}
|
||||
|
|
|
|||
17
api/src/jobs/cron.ts
Normal file
17
api/src/jobs/cron.ts
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
// Cron Router
|
||||
import { updateThemeparkData } from "./update-themepark-data";
|
||||
|
||||
export default async function cronRouter(
|
||||
event: ScheduledEvent,
|
||||
env: Env,
|
||||
ctx: ExecutionContext,
|
||||
){
|
||||
switch (event.cron){
|
||||
case '* * * * *':
|
||||
console.log('every minute');
|
||||
break;
|
||||
default:
|
||||
console.log('its me - the cron router');
|
||||
break;
|
||||
}
|
||||
}
|
||||
7459
api/worker-configuration.d.ts
vendored
Normal file
7459
api/worker-configuration.d.ts
vendored
Normal file
File diff suppressed because it is too large
Load diff
|
|
@ -29,6 +29,12 @@
|
|||
"migrations_dir": "drizzle/migrations"
|
||||
}
|
||||
],
|
||||
"triggers": {
|
||||
"crons": [
|
||||
"0 4 7,14,21,28 * *", // At 04:00 on day-of-month 7, 14, 21, and 28.
|
||||
"* * * * *" // every minute
|
||||
]
|
||||
}
|
||||
// "ai": {
|
||||
// "binding": "AI"
|
||||
// },
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue