Browse Source

refactor(rss-scheduler): streamline plugin initialization and interval setup

- Simplified the plugin definition by removing the nitroApp parameter.
- Consolidated the interval and timeout setup for syncing feeds into a more concise format.
feat/multitenant-hub
npmrun 8 hours ago
parent
commit
596aa167d6
  1. 28
      server/plugins/04.rss-scheduler.ts

28
server/plugins/04.rss-scheduler.ts

@ -2,21 +2,19 @@ import { syncAllDueFeeds } from "#server/service/rss";
const MIN_INTERVAL_MS = 60_000;
export default defineNitroPlugin((nitroApp) => {
nitroApp.hooks.hook("ready", () => {
const minutes = Number(process.env.RSS_SYNC_INTERVAL_MINUTES ?? 60);
const intervalMs = Math.max(minutes * 60_000, MIN_INTERVAL_MS);
export default defineNitroPlugin(() => {
const minutes = Number(process.env.RSS_SYNC_INTERVAL_MINUTES ?? 60);
const intervalMs = Math.max(minutes * 60_000, MIN_INTERVAL_MS);
setInterval(() => {
syncAllDueFeeds().catch((e) => {
console.error("[rss-scheduler]", e);
});
}, intervalMs);
setInterval(() => {
syncAllDueFeeds().catch((e) => {
console.error("[rss-scheduler]", e);
});
}, intervalMs);
setTimeout(() => {
syncAllDueFeeds().catch((e) => {
console.error("[rss-scheduler] startup", e);
});
}, 5000);
});
setTimeout(() => {
syncAllDueFeeds().catch((e) => {
console.error("[rss-scheduler] startup", e);
});
}, 5000);
});

Loading…
Cancel
Save