@wabot-dev/framework 0.1.0-beta.41 → 0.1.0-beta.42
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.
|
@@ -32,7 +32,7 @@ class PgCrudRepository extends PgRepositoryBase {
|
|
|
32
32
|
const item = await this.find(id);
|
|
33
33
|
if (!item) {
|
|
34
34
|
throw new CustomError({
|
|
35
|
-
message: `Not found ${this.config.constructor.name} with id = '${id}'
|
|
35
|
+
message: `Not found ${this.config.constructor.name} with id = '${id}'`,
|
|
36
36
|
httpCode: 404,
|
|
37
37
|
});
|
|
38
38
|
}
|
|
@@ -70,7 +70,7 @@ function runRestControllers(controllers) {
|
|
|
70
70
|
}, {});
|
|
71
71
|
res
|
|
72
72
|
.status(httpCode ?? 500)
|
|
73
|
-
.json({ error: { message: err.message, stack: err.stack, ...info } });
|
|
73
|
+
.json(removeCircular({ error: { message: err.message, stack: err.stack, ...info } }));
|
|
74
74
|
}
|
|
75
75
|
else {
|
|
76
76
|
res.status(500).json({ error: { message: 'Unknown error' } });
|
|
@@ -84,5 +84,19 @@ function runRestControllers(controllers) {
|
|
|
84
84
|
});
|
|
85
85
|
expressProvider.listen();
|
|
86
86
|
}
|
|
87
|
+
function removeCircular(obj, seen = new WeakSet()) {
|
|
88
|
+
if (obj && typeof obj === 'object') {
|
|
89
|
+
if (seen.has(obj)) {
|
|
90
|
+
return undefined; // remove circular ref
|
|
91
|
+
}
|
|
92
|
+
seen.add(obj);
|
|
93
|
+
const clone = Array.isArray(obj) ? [] : {};
|
|
94
|
+
for (const key in obj) {
|
|
95
|
+
clone[key] = removeCircular(obj[key], seen);
|
|
96
|
+
}
|
|
97
|
+
return clone;
|
|
98
|
+
}
|
|
99
|
+
return obj;
|
|
100
|
+
}
|
|
87
101
|
|
|
88
102
|
export { runRestControllers };
|