Jamesllllllllll / beacons-link-checker

Check if you have broken links on your Beacons page
https://beacons-link-checker.vercel.app
3 stars 2 forks source link

Sending notifications #13

Closed Jamesllllllllll closed 9 months ago

Jamesllllllllll commented 10 months ago
Jamesllllllllll commented 10 months ago

I set up a CRON job to check a mocked up data set and send emails based on the results.

I need to work on error handling, they currently cause the link checker to bail out and not send an email.

Jamesllllllllll commented 10 months ago

So CRON jobs will only actually run in full "production" - meaning none of the development deployments (good thing, as it could potentially run & send multiple emails).

Currently the CRON job is set to run hourly for a single username and email me. I will monitor today to see if it's working!

Jamesllllllllll commented 9 months ago

I have a CRON job that runs /api/weeklyCron set up to take an array of users from the db and in turn calls /api/checkWeekly for each user.

There was an issue with weeklyCron not being detected as a serverless function by Vercel. One line of code was required on that endpoint to force Vercel to do so:

export const dynamic = 'force-dynamic'

The checkWeekly function is a single function that combines /api/checkBeacons and loops through each link calling /api/checkHeaders - and finally sends an email through SendGrid when it's complete if there are any warnings or errors for the links.

Next steps: