diff --git a/README.md b/README.md index 26ee3b6..c55548b 100644 --- a/README.md +++ b/README.md @@ -67,7 +67,6 @@ might be easier (although I require Node APIs, I believe). - `/api/cron` is the primary cron-job endpoint. Authorization required. - `?report=true` is assumed, and when `true`, Cronitor will be notified of the job's status. - `?dry=true` will not send any notifications or effects, but will still perform all checks and logging for runtime testing. - - `?force=true` will skip configuration time checks and send notifications regardless of how long it's been since the last notification. - `/api/health` is a simple health check endpoint. Authorization optional. - `/api/check` is a simple endpoint to check authorization. - `/api/config` is the configuration endpoint. Authorization required. diff --git a/src/pages/api/cron.ts b/src/pages/api/cron.ts index 428cb63..c44c201 100644 --- a/src/pages/api/cron.ts +++ b/src/pages/api/cron.ts @@ -87,10 +87,19 @@ export default async function handler( identifier }; + const isDry = parseBoolean(req.query.dry ?? 'false'); + logger.info( + !isDry + ? 'Sending notification, marking identifier.' + : 'Dry run, not sending notification or marking identifier.', + { identifier } + ); + // Send notification, mark (expire in 1 month) - logger.info('Sending notification, marking identifier.', { identifier }); - await sendNotification(`${matching.message} (${matching.name})`); - await markIdentifier(key, true, 60 * 60 * 24 * 31); + if (!isDry) { + await sendNotification(`${matching.message} (${matching.name})`); + await markIdentifier(key, true, 60 * 60 * 24 * 31); + } return { status: 'notified', identifier }; }