Implement dry run, remove ?force from README

This commit is contained in:
2023-09-05 15:31:26 -05:00
parent 77690b37e7
commit 877e48abed
2 changed files with 12 additions and 4 deletions

View File

@@ -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.

View File

@@ -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 });
if (!isDry) {
await sendNotification(`${matching.message} (${matching.name})`);
await markIdentifier(key, true, 60 * 60 * 24 * 31);
}
return { status: 'notified', identifier };
}