powr-sdk-api 3.0.3 → 3.0.4

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.
@@ -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
- return res.status(200).json({
247
- success: true,
248
- data: result
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({
@@ -71,7 +71,11 @@ class PlexxManager {
71
71
  }
72
72
  async execute(projectId, route, params) {
73
73
  if (!this.isEnabled) {
74
- throw new Error("Plexx is disabled");
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
- throw new Error(`Route not found: ${route}`);
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
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "powr-sdk-api",
3
- "version": "3.0.3",
3
+ "version": "3.0.4",
4
4
  "description": "Shared API core library for PowrStack projects",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",