powr-sdk-api 3.0.3 → 3.0.5
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/dist/routes/plexx.js +15 -4
- package/dist/services/plexx.js +25 -3
- package/package.json +1 -1
package/dist/routes/plexx.js
CHANGED
|
@@ -243,10 +243,21 @@ router.post("/:route", async (req, res) => {
|
|
|
243
243
|
...req.body
|
|
244
244
|
};
|
|
245
245
|
const result = await plexxManager.execute(projectId, route, params);
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
246
|
+
|
|
247
|
+
// Handle the standardized response format
|
|
248
|
+
if (result.success) {
|
|
249
|
+
return res.status(200).json({
|
|
250
|
+
success: true,
|
|
251
|
+
data: result.data,
|
|
252
|
+
message: result.message
|
|
253
|
+
});
|
|
254
|
+
} else {
|
|
255
|
+
return res.status(404).json({
|
|
256
|
+
success: false,
|
|
257
|
+
message: result.message,
|
|
258
|
+
data: result.data
|
|
259
|
+
});
|
|
260
|
+
}
|
|
250
261
|
} catch (err) {
|
|
251
262
|
console.error("Error executing logic:", err);
|
|
252
263
|
return res.status(500).json({
|
package/dist/services/plexx.js
CHANGED
|
@@ -71,7 +71,11 @@ class PlexxManager {
|
|
|
71
71
|
}
|
|
72
72
|
async execute(projectId, route, params) {
|
|
73
73
|
if (!this.isEnabled) {
|
|
74
|
-
|
|
74
|
+
return {
|
|
75
|
+
success: false,
|
|
76
|
+
message: "Plexx is disabled",
|
|
77
|
+
data: null
|
|
78
|
+
};
|
|
75
79
|
}
|
|
76
80
|
const cacheKey = `${projectId}:${route}`;
|
|
77
81
|
const cached = this.compiledFunctions.get(cacheKey);
|
|
@@ -84,9 +88,27 @@ class PlexxManager {
|
|
|
84
88
|
return retryCached.function(params);
|
|
85
89
|
}
|
|
86
90
|
}
|
|
87
|
-
|
|
91
|
+
return {
|
|
92
|
+
success: false,
|
|
93
|
+
message: `Route not found: ${route}`,
|
|
94
|
+
data: null
|
|
95
|
+
};
|
|
96
|
+
}
|
|
97
|
+
try {
|
|
98
|
+
const result = cached.function(params);
|
|
99
|
+
return {
|
|
100
|
+
success: true,
|
|
101
|
+
message: "Route executed successfully",
|
|
102
|
+
data: result
|
|
103
|
+
};
|
|
104
|
+
} catch (error) {
|
|
105
|
+
return {
|
|
106
|
+
success: false,
|
|
107
|
+
message: `Error executing route: ${error.message}`,
|
|
108
|
+
data: null,
|
|
109
|
+
error: error.message
|
|
110
|
+
};
|
|
88
111
|
}
|
|
89
|
-
return cached.function(params);
|
|
90
112
|
}
|
|
91
113
|
|
|
92
114
|
// Load specific route for central service
|