* chore: Remove all code related to the old cache system * Removed some redundant tests, some type fixes * Further type fixes * More type fixes re. tests * Next iteration, couple of fixes remaining * Remove cache from CredentialActionsDropdown * Fix tests by mocking credential, instead of db queries * Remove Cache DI wiring from v2 * Make sure apiv2 build passes * Remove another cache cron * Remove old tokens for calendar-cache v1
39 lines
954 B
TypeScript
Executable File
39 lines
954 B
TypeScript
Executable File
import { CronJob } from "cron";
|
|
import dotEnv from "dotenv";
|
|
|
|
dotEnv.config({ path: "../../.env" });
|
|
|
|
async function fetchCron(endpoint: string) {
|
|
const apiKey = process.env.CRON_API_KEY;
|
|
|
|
const res = await fetch(`http://localhost:3000/api${endpoint}?apiKey=${apiKey}`, {
|
|
headers: {
|
|
"Content-Type": "application/json",
|
|
authorization: `Bearer ${process.env.CRON_SECRET}`,
|
|
},
|
|
});
|
|
const json = await res.json();
|
|
console.log(endpoint, json);
|
|
}
|
|
|
|
try {
|
|
console.log("⏳ Running cron endpoints");
|
|
new CronJob(
|
|
// Each 5 seconds
|
|
"*/5 * * * * *",
|
|
async function () {
|
|
await Promise.allSettled([
|
|
fetchCron("/cron/calendar-subscriptions"),
|
|
// fetchCron("/cron/calVideoNoShowWebhookTriggers"),
|
|
fetchCron("/tasks/cron"),
|
|
]);
|
|
},
|
|
null,
|
|
true,
|
|
"America/Los_Angeles"
|
|
);
|
|
} catch (_err) {
|
|
console.error("❌ ❌ ❌ Something went wrong ❌ ❌ ❌");
|
|
process.exit(1);
|
|
}
|