@rmdes/indiekit-endpoint-rss 1.0.1 → 1.0.2
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/lib/controllers/dashboard.js +11 -5
- package/lib/sync.js +5 -4
- package/package.json +1 -1
|
@@ -65,15 +65,21 @@ export const dashboardController = {
|
|
|
65
65
|
*/
|
|
66
66
|
async sync(request, response) {
|
|
67
67
|
try {
|
|
68
|
-
const
|
|
69
|
-
const { rssConfig } = request.app.locals.application;
|
|
68
|
+
const { rssConfig, getRssDb } = request.app.locals.application;
|
|
70
69
|
|
|
71
|
-
if (!
|
|
70
|
+
if (!rssConfig) {
|
|
72
71
|
return response.status(500).json({
|
|
73
72
|
error: response.locals.__("rss.error.noConfig"),
|
|
74
73
|
});
|
|
75
74
|
}
|
|
76
75
|
|
|
76
|
+
const db = getRssDb?.();
|
|
77
|
+
if (!db) {
|
|
78
|
+
return response.status(500).json({
|
|
79
|
+
error: response.locals.__("rss.error.noDatabase"),
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
|
|
77
83
|
const syncState = getSyncState();
|
|
78
84
|
if (syncState.syncing) {
|
|
79
85
|
return response.status(409).json({
|
|
@@ -82,8 +88,8 @@ export const dashboardController = {
|
|
|
82
88
|
});
|
|
83
89
|
}
|
|
84
90
|
|
|
85
|
-
// Start sync and wait for result
|
|
86
|
-
const result = await runSync(
|
|
91
|
+
// Start sync and wait for result - pass db directly
|
|
92
|
+
const result = await runSync(db, rssConfig);
|
|
87
93
|
|
|
88
94
|
if (result.error) {
|
|
89
95
|
return response.status(500).json({
|
package/lib/sync.js
CHANGED
|
@@ -57,13 +57,14 @@ export function stopSync() {
|
|
|
57
57
|
|
|
58
58
|
/**
|
|
59
59
|
* Run a single sync cycle
|
|
60
|
-
* @param {Object}
|
|
60
|
+
* @param {Object} dbOrIndiekit - Database instance or Indiekit instance (for backwards compat)
|
|
61
61
|
* @param {Object} options - Plugin options
|
|
62
62
|
* @returns {Promise<Object>}
|
|
63
63
|
*/
|
|
64
|
-
export async function runSync(
|
|
65
|
-
|
|
66
|
-
|
|
64
|
+
export async function runSync(dbOrIndiekit, options) {
|
|
65
|
+
// Support both direct db object and Indiekit object (for background sync)
|
|
66
|
+
const db = dbOrIndiekit.database || dbOrIndiekit;
|
|
67
|
+
if (!db || typeof db.collection !== "function") {
|
|
67
68
|
syncState.lastError = "No database available";
|
|
68
69
|
return { error: syncState.lastError };
|
|
69
70
|
}
|
package/package.json
CHANGED