mirror of
https://github.com/Xevion/bus-reminder.git
synced 2025-12-06 01:14:30 -06:00
Implement dry run, remove ?force from README
This commit is contained in:
@@ -67,7 +67,6 @@ might be easier (although I require Node APIs, I believe).
|
|||||||
- `/api/cron` is the primary cron-job endpoint. Authorization required.
|
- `/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.
|
- `?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.
|
- `?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/health` is a simple health check endpoint. Authorization optional.
|
||||||
- `/api/check` is a simple endpoint to check authorization.
|
- `/api/check` is a simple endpoint to check authorization.
|
||||||
- `/api/config` is the configuration endpoint. Authorization required.
|
- `/api/config` is the configuration endpoint. Authorization required.
|
||||||
|
|||||||
@@ -87,10 +87,19 @@ export default async function handler(
|
|||||||
identifier
|
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)
|
// Send notification, mark (expire in 1 month)
|
||||||
logger.info('Sending notification, marking identifier.', { identifier });
|
if (!isDry) {
|
||||||
await sendNotification(`${matching.message} (${matching.name})`);
|
await sendNotification(`${matching.message} (${matching.name})`);
|
||||||
await markIdentifier(key, true, 60 * 60 * 24 * 31);
|
await markIdentifier(key, true, 60 * 60 * 24 * 31);
|
||||||
|
}
|
||||||
|
|
||||||
return { status: 'notified', identifier };
|
return { status: 'notified', identifier };
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user