diff --git a/docs/dependency-updates.md b/docs/dependency-updates.md index 8588673d2d6..998e6bf7515 100644 --- a/docs/dependency-updates.md +++ b/docs/dependency-updates.md @@ -200,8 +200,8 @@ Used to compile cronjob scripts. You can test this by running ### `tsx` Used to run cronjobs locally and compile them on the fly. You can verify this by -running `npm run dev:cronjobs`; if the cronjobs run like in `main`, it's still -working. +running a cronjob like `npm run dev:cron:monthly-activity`; if the cronjobs run +like in `main`, it's still working. ### `yaml` diff --git a/esbuild.cronjobs.js b/esbuild.cronjobs.js index 3ba18f58f60..b8be0739677 100644 --- a/esbuild.cronjobs.js +++ b/esbuild.cronjobs.js @@ -14,7 +14,7 @@ import { build } from "esbuild"; // own issues in Next.js. Thus, esbuild is a compromise that can resolve these // import specifiers for us. build({ - entryPoints: ["./src/scripts/cronjobs/**/*.tsx"], + entryPoints: ["./src/scripts/cronjobs/**/*.tsx", "./src/scripts/cronjobs/**/*.ts"], tsconfig: "tsconfig.cronjobs.json", bundle: true, platform: "node", diff --git a/package.json b/package.json index 0ae3767846a..c687e5f712a 100644 --- a/package.json +++ b/package.json @@ -9,7 +9,9 @@ "type": "module", "scripts": { "dev": "npm run build-nimbus && next dev --port=6060", - "dev:cronjobs": "tsx --tsconfig tsconfig.cronjobs.json src/scripts/cronjobs/*.tsx", + "dev:cron:first-data-broker-removal-fixed": "tsx --tsconfig tsconfig.cronjobs.json src/scripts/cronjobs/firstDataBrokerRemovalFixed.tsx", + "dev:cron:monthly-activity": "tsx --tsconfig tsconfig.cronjobs.json src/scripts/cronjobs/monthlyActivity.tsx", + "dev:cron:db-delete-unverified-subscribers": "tsx --tsconfig tsconfig.cronjobs.json src/scripts/cronjobs/deleteUnverifiedSubscribers.ts", "dev:nimbus": "node --watch-path config/nimbus.yaml src/scripts/build/nimbusTypes.js", "build": "npm run get-location-data && npm run build-glean && npm run build-nimbus && next build && npm run build-cronjobs", "cloudrun": "npm run db:migrate && npm start", @@ -23,7 +25,7 @@ "cron:first-data-broker-removal-fixed": "node dist/scripts/cronjobs/firstDataBrokerRemovalFixed.js", "cron:monthly-activity": "node dist/scripts/cronjobs/monthlyActivity.js", "cron:breach-alerts": "node src/scripts/emailBreachAlerts.js", - "cron:db-delete-unverified-subscribers": "node scripts/delete-unverified-subscribers.js", + "cron:db-delete-unverified-subscribers": "node dist/scripts/cronjobs/deleteUnverifiedSubscribers.js", "cron:db-pull-breaches": "node src/scripts/syncBreaches.js", "cron:remote-settings-pull-breaches": "node scripts/updatebreaches.js", "cron:onerep-limits-alert": "node src/scripts/onerepStatsAlert.js", diff --git a/scripts/delete-unverified-subscribers.js b/scripts/delete-unverified-subscribers.js deleted file mode 100644 index 5d464813a6f..00000000000 --- a/scripts/delete-unverified-subscribers.js +++ /dev/null @@ -1,12 +0,0 @@ -'use strict' - -import { deleteUnverifiedSubscribers } from '../src/db/tables/subscribers.js'; - -/** - * Cron: Hourly - * Delete any records of subscribers not verified within 24 hrs - */ -(async () => { - await deleteUnverifiedSubscribers() - process.exit() -})() diff --git a/src/scripts/cronjobs/deleteUnverifiedSubscribers.ts b/src/scripts/cronjobs/deleteUnverifiedSubscribers.ts new file mode 100644 index 00000000000..b3c337aea7f --- /dev/null +++ b/src/scripts/cronjobs/deleteUnverifiedSubscribers.ts @@ -0,0 +1,12 @@ +"use strict"; + +import { deleteUnverifiedSubscribers } from "../../db/tables/subscribers"; + +/** + * Cron: Hourly + * Delete any records of subscribers not verified within 24 hrs + */ +(async () => { + await deleteUnverifiedSubscribers(); + process.exit(); +})();