Created
July 7, 2023 20:52
-
-
Save wtachau/fb0ad5688a8b324d850deb0c191185d7 to your computer and use it in GitHub Desktop.
api/cron endpoint
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import { noopQuery } from '$lib/server/neo4j'; | |
| import { success } from '$lib/server/response'; | |
| import { isProd } from '@common/environment'; | |
| import type { RequestHandler } from './$types'; | |
| export const GET: RequestHandler = async ({ locals: { ctx } }) => { | |
| ctx.log('[CRON JOB RUNNING]'); | |
| await noopQuery(ctx); | |
| // Vercel doesn't run cron jobs in Preview, so manually ping the /api/cron endpoint when | |
| // the prod cronjob runs | |
| if (isProd) { | |
| ctx.log('[Triggering Preview Cron]'); | |
| await fetch('https://preview.whynemo.com/api/cron'); | |
| } | |
| return success({}); | |
| }; |
Author
wtachau
commented
Jul 7, 2023
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment