From 596aa167d6d21b7d944f18191242d1bf8efd6c97 Mon Sep 17 00:00:00 2001 From: npmrun <1549469775@qq.com> Date: Sat, 18 Apr 2026 14:35:20 +0800 Subject: [PATCH] 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. --- server/plugins/04.rss-scheduler.ts | 28 +++++++++++++--------------- 1 file changed, 13 insertions(+), 15 deletions(-) diff --git a/server/plugins/04.rss-scheduler.ts b/server/plugins/04.rss-scheduler.ts index 99e2bbb..40804dc 100644 --- a/server/plugins/04.rss-scheduler.ts +++ b/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); });