* WIP * WIP * WIP * WIP * WIP * WIP * WIP * WIP * WIP * Update CalendarService.ts * Type fixes * WIP * fix: improve cache hits * Update CalendarService.ts * Update CalendarService.ts * Update CalendarService.ts * Update CalendarService.ts * Update CalendarService.ts * Update CalendarService.ts * Feedback * Update CalendarService.ts * Update CalendarService.ts * Update _router.ts * feedback * WIP * WIP * Update schema.prisma * feedback * typefixes * Update Calendar.d.ts * fix: watches when adding a calendar * Discard changes to packages/app-store/googlecalendar/api/add.ts * WIP Signed-off-by: Omar López <zomars@me.com> * WIP Signed-off-by: Omar López <zomars@me.com> * WP Signed-off-by: Omar López <zomars@me.com> * Update calendar.ts * Update calendar.ts * Update callback.ts * Update callback.ts * Conflicts * WIP * WIP * Update CalendarService.ts * Cleanup * Discard changes to packages/features/settings/layouts/SettingsLayout.tsx * Update calendar-cache.repository.ts * WIP * Update getSelectedCalendarsToWatch.sql * WIP * Update CalendarService.ts * Cleanup * Discard changes to packages/app-store/googlecalendar/lib/CalendarService.ts * Create CalendarService.wip.ts * WIP * Update CalendarService.ts * Update getSelectedCalendarsToWatch.sql * Delete CalendarService.wip.ts * test updates * cleanup Signed-off-by: Omar López <zomars@me.com> * Update CalendarService.test.ts * Update CalendarService.ts * type fixes * Update OAuthManager.ts * Update CalendarService.ts * Almost there * Update CalendarService.test.ts * Update calendar.ts * Update callback.ts * Update toggleFeatureFlag.handler.ts * fix: feedback * Update getSelectedCalendarsToWatch.sql * Fix unit tests --------- Signed-off-by: Omar López <zomars@me.com> Co-authored-by: Udit Takkar <53316345+Udit-takkar@users.noreply.github.com>
40 lines
963 B
TypeScript
40 lines
963 B
TypeScript
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("/calendar-cache/cron"),
|
|
// fetchCron("/cron/calVideoNoShowWebhookTriggers"),
|
|
//
|
|
// fetchCron("/tasks/cleanup"),
|
|
]);
|
|
},
|
|
null,
|
|
true,
|
|
"America/Los_Angeles"
|
|
);
|
|
} catch (_err) {
|
|
console.error("❌ ❌ ❌ Something went wrong ❌ ❌ ❌");
|
|
process.exit(1);
|
|
}
|