carta-controller 5.0.0 → 5.0.3-patch1
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/README.md +2 -2
- package/dist/database.js +14 -5
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
# CARTA Controller
|
|
2
2
|
|
|
3
|
-
[](https://www.npmjs.com/package/carta-controller/v/latest)
|
|
4
|
+
[](https://www.npmjs.com/package/carta-controller/v/beta)
|
|
5
5
|

|
|
6
6
|

|
|
7
7
|
|
package/dist/database.js
CHANGED
|
@@ -29,12 +29,14 @@ const preferenceSchema = require("../schemas/preferences_schema_2.json");
|
|
|
29
29
|
const layoutSchema = require("../schemas/layout_schema_2.json");
|
|
30
30
|
const snippetSchema = require("../schemas/snippet_schema_1.json");
|
|
31
31
|
const workspaceSchema = require("../schemas/workspace_schema_1.json");
|
|
32
|
-
const ajv = new ajv_1.default({ useDefaults:
|
|
32
|
+
const ajv = new ajv_1.default({ useDefaults: false, strictTypes: false });
|
|
33
|
+
const ajvWithDefaults = new ajv_1.default({ useDefaults: true, strictTypes: false });
|
|
33
34
|
(0, ajv_formats_1.default)(ajv);
|
|
35
|
+
(0, ajv_formats_1.default)(ajvWithDefaults);
|
|
34
36
|
const validatePreferences = ajv.compile(preferenceSchema);
|
|
35
|
-
const validateLayout =
|
|
36
|
-
const validateSnippet =
|
|
37
|
-
const validateWorkspace =
|
|
37
|
+
const validateLayout = ajvWithDefaults.compile(layoutSchema);
|
|
38
|
+
const validateSnippet = ajvWithDefaults.compile(snippetSchema);
|
|
39
|
+
const validateWorkspace = ajvWithDefaults.compile(workspaceSchema);
|
|
38
40
|
let client;
|
|
39
41
|
let preferenceCollection;
|
|
40
42
|
let layoutsCollection;
|
|
@@ -111,7 +113,7 @@ function handleGetPreferences(req, res, next) {
|
|
|
111
113
|
res.json({ success: true, preferences: doc });
|
|
112
114
|
}
|
|
113
115
|
else {
|
|
114
|
-
|
|
116
|
+
res.json({ success: true, preferences: {} });
|
|
115
117
|
}
|
|
116
118
|
}
|
|
117
119
|
catch (err) {
|
|
@@ -131,6 +133,7 @@ function handleSetPreferences(req, res, next) {
|
|
|
131
133
|
const update = req.body;
|
|
132
134
|
// Check for malformed update
|
|
133
135
|
if (!update || !Object.keys(update).length || update.username || update._id) {
|
|
136
|
+
util_1.logger.warning("Malformed preference update received");
|
|
134
137
|
return next({ statusCode: 400, message: "Malformed preference update" });
|
|
135
138
|
}
|
|
136
139
|
update.version = PREFERENCE_SCHEMA_VERSION;
|
|
@@ -142,9 +145,11 @@ function handleSetPreferences(req, res, next) {
|
|
|
142
145
|
try {
|
|
143
146
|
const updateResult = yield preferenceCollection.updateOne({ username: req.username }, { $set: update }, { upsert: true });
|
|
144
147
|
if (updateResult.acknowledged) {
|
|
148
|
+
util_1.logger.debug("Preferences updated");
|
|
145
149
|
res.json({ success: true });
|
|
146
150
|
}
|
|
147
151
|
else {
|
|
152
|
+
util_1.logger.warning("Error updating preferences");
|
|
148
153
|
return next({ statusCode: 500, message: "Problem updating preferences" });
|
|
149
154
|
}
|
|
150
155
|
}
|
|
@@ -166,6 +171,7 @@ function handleClearPreferences(req, res, next) {
|
|
|
166
171
|
const keys = (_a = req.body) === null || _a === void 0 ? void 0 : _a.keys;
|
|
167
172
|
// Check for malformed update
|
|
168
173
|
if (!keys || !Array.isArray(keys) || !keys.length) {
|
|
174
|
+
util_1.logger.debug("Malformed key list received for clearing preferences");
|
|
169
175
|
return next({ statusCode: 400, message: "Malformed key list" });
|
|
170
176
|
}
|
|
171
177
|
const update = {};
|
|
@@ -175,13 +181,16 @@ function handleClearPreferences(req, res, next) {
|
|
|
175
181
|
try {
|
|
176
182
|
const updateResult = yield preferenceCollection.updateOne({ username: req.username }, { $unset: update });
|
|
177
183
|
if (updateResult.acknowledged) {
|
|
184
|
+
util_1.logger.debug("Preferences cleared");
|
|
178
185
|
res.json({ success: true });
|
|
179
186
|
}
|
|
180
187
|
else {
|
|
188
|
+
util_1.logger.debug("Error clearing preferences");
|
|
181
189
|
return next({ statusCode: 500, message: "Problem clearing preferences" });
|
|
182
190
|
}
|
|
183
191
|
}
|
|
184
192
|
catch (err) {
|
|
193
|
+
util_1.logger.debug("Error clearing preferences");
|
|
185
194
|
util_1.logger.debug(err);
|
|
186
195
|
return next({ statusCode: 500, message: "Problem clearing preferences" });
|
|
187
196
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "carta-controller",
|
|
3
|
-
"version": "5.0.
|
|
3
|
+
"version": "5.0.3-patch1",
|
|
4
4
|
"description": "NodeJS-based controller for CARTA",
|
|
5
5
|
"repository": "https://github.com/CARTAvis/carta-controller",
|
|
6
6
|
"homepage": "https://www.cartavis.org",
|
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
"ajv-formats": "^3.0.1",
|
|
26
26
|
"axios": "^1.8.2",
|
|
27
27
|
"body-parser": "^1.19.0",
|
|
28
|
-
"carta-frontend": "^5.0.
|
|
28
|
+
"carta-frontend": "^5.0.3",
|
|
29
29
|
"compression": "^1.8.0",
|
|
30
30
|
"cookie-parser": "^1.4.7",
|
|
31
31
|
"cors": "^2.8.5",
|
|
@@ -60,7 +60,7 @@
|
|
|
60
60
|
"@types/cors": "^2.8.10",
|
|
61
61
|
"@types/express": "^4.17.11",
|
|
62
62
|
"@types/http-proxy": "^1.17.16",
|
|
63
|
-
"@types/jsonwebtoken": "
|
|
63
|
+
"@types/jsonwebtoken": "9.0.6",
|
|
64
64
|
"@types/lodash": "^4.17.15",
|
|
65
65
|
"@types/ms": "^0.7.31",
|
|
66
66
|
"@types/node": "^22.13.1",
|