@rmdes/indiekit-endpoint-microsub 1.0.58 → 1.0.61
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.js +34 -26
- package/package.json +2 -1
package/index.js
CHANGED
|
@@ -3,6 +3,7 @@ import { fileURLToPath } from "node:url";
|
|
|
3
3
|
|
|
4
4
|
import express from "express";
|
|
5
5
|
import rateLimit from "express-rate-limit";
|
|
6
|
+
import { waitForReady } from "@rmdes/indiekit-startup-gate";
|
|
6
7
|
|
|
7
8
|
import { microsubController } from "./lib/controllers/microsub.js";
|
|
8
9
|
import { opmlController } from "./lib/controllers/opml.js";
|
|
@@ -202,38 +203,44 @@ export default class MicrosubEndpoint {
|
|
|
202
203
|
// Start feed polling scheduler when server starts
|
|
203
204
|
// This will be called after the server is ready
|
|
204
205
|
if (indiekit.database) {
|
|
205
|
-
|
|
206
|
-
startScheduler(indiekit);
|
|
207
|
-
|
|
208
|
-
// Ensure system channels exist
|
|
209
|
-
ensureActivityPubChannel(indiekit).catch((error) => {
|
|
210
|
-
console.warn(
|
|
211
|
-
"[Microsub] ActivityPub channel creation failed:",
|
|
212
|
-
error.message,
|
|
213
|
-
);
|
|
214
|
-
});
|
|
215
|
-
|
|
216
|
-
// Create indexes for optimal performance (runs in background)
|
|
206
|
+
// Indexes are cheap and idempotent — create immediately
|
|
217
207
|
createIndexes(indiekit).catch((error) => {
|
|
218
208
|
console.warn("[Microsub] Index creation failed:", error.message);
|
|
219
209
|
});
|
|
220
210
|
|
|
221
|
-
//
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
211
|
+
// Defer heavy tasks until host is ready
|
|
212
|
+
this._stopGate = waitForReady(
|
|
213
|
+
() => {
|
|
214
|
+
console.info("[Microsub] Starting scheduler and maintenance tasks");
|
|
215
|
+
startScheduler(indiekit);
|
|
225
216
|
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
217
|
+
// Ensure system channels exist
|
|
218
|
+
ensureActivityPubChannel(indiekit).catch((error) => {
|
|
219
|
+
console.warn(
|
|
220
|
+
"[Microsub] ActivityPub channel creation failed:",
|
|
221
|
+
error.message,
|
|
222
|
+
);
|
|
223
|
+
});
|
|
230
224
|
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
225
|
+
// Cleanup old read items on startup
|
|
226
|
+
cleanupAllReadItems(indiekit).catch((error) => {
|
|
227
|
+
console.warn("[Microsub] Startup cleanup failed:", error.message);
|
|
228
|
+
});
|
|
229
|
+
|
|
230
|
+
// Delete stale items (stripped skeletons + unread older than 30 days)
|
|
231
|
+
cleanupStaleItems(indiekit).catch((error) => {
|
|
232
|
+
console.warn("[Microsub] Stale cleanup failed:", error.message);
|
|
233
|
+
});
|
|
234
|
+
|
|
235
|
+
// Schedule daily stale cleanup (items accumulate between restarts)
|
|
236
|
+
setInterval(() => {
|
|
237
|
+
cleanupStaleItems(indiekit).catch((error) => {
|
|
238
|
+
console.warn("[Microsub] Scheduled stale cleanup failed:", error.message);
|
|
239
|
+
});
|
|
240
|
+
}, 24 * 60 * 60 * 1000);
|
|
241
|
+
},
|
|
242
|
+
{ label: "Microsub" },
|
|
243
|
+
);
|
|
237
244
|
} else {
|
|
238
245
|
console.warn(
|
|
239
246
|
"[Microsub] Database not available at init, scheduler not started",
|
|
@@ -245,6 +252,7 @@ export default class MicrosubEndpoint {
|
|
|
245
252
|
* Cleanup on shutdown
|
|
246
253
|
*/
|
|
247
254
|
destroy() {
|
|
255
|
+
this._stopGate?.();
|
|
248
256
|
stopScheduler();
|
|
249
257
|
}
|
|
250
258
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rmdes/indiekit-endpoint-microsub",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.61",
|
|
4
4
|
"description": "Microsub endpoint for Indiekit. Enables subscribing to feeds and reading content using the Microsub protocol.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"indiekit",
|
|
@@ -37,6 +37,7 @@
|
|
|
37
37
|
},
|
|
38
38
|
"dependencies": {
|
|
39
39
|
"@indiekit/error": "^1.0.0-beta.25",
|
|
40
|
+
"@rmdes/indiekit-startup-gate": "^1.0.0",
|
|
40
41
|
"@indiekit/frontend": "^1.0.0-beta.25",
|
|
41
42
|
"@indiekit/util": "^1.0.0-beta.25",
|
|
42
43
|
"debug": "^4.3.2",
|