@modular-rest/server 1.11.4 → 1.11.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/package.json
CHANGED
|
@@ -19,7 +19,10 @@ dataProvider.use("/", middleware.auth, async (ctx, next) => {
|
|
|
19
19
|
|
|
20
20
|
// fields validation
|
|
21
21
|
if (!bodyValidated.isValid) {
|
|
22
|
-
ctx.throw(
|
|
22
|
+
ctx.throw(
|
|
23
|
+
412,
|
|
24
|
+
JSON.stringify(reply("e", { error: bodyValidated.requires }))
|
|
25
|
+
);
|
|
23
26
|
}
|
|
24
27
|
|
|
25
28
|
// type caster
|
|
@@ -57,7 +60,10 @@ dataProvider.post("/find", async (ctx) => {
|
|
|
57
60
|
|
|
58
61
|
// fields validation
|
|
59
62
|
if (!bodyValidate.isValid) {
|
|
60
|
-
ctx.throw(
|
|
63
|
+
ctx.throw(
|
|
64
|
+
412,
|
|
65
|
+
JSON.stringify(reply("e", { error: bodyValidate.requires }))
|
|
66
|
+
);
|
|
61
67
|
}
|
|
62
68
|
|
|
63
69
|
// access validation
|
|
@@ -79,7 +85,7 @@ dataProvider.post("/find", async (ctx) => {
|
|
|
79
85
|
if (collection == null) {
|
|
80
86
|
ctx.throw(
|
|
81
87
|
412,
|
|
82
|
-
JSON.stringify(reply("e", {
|
|
88
|
+
JSON.stringify(reply("e", { error: "wrong database or collection" }))
|
|
83
89
|
);
|
|
84
90
|
}
|
|
85
91
|
|
|
@@ -125,7 +131,10 @@ dataProvider.post("/find-one", async (ctx) => {
|
|
|
125
131
|
|
|
126
132
|
// fields validation
|
|
127
133
|
if (!bodyValidate.isValid) {
|
|
128
|
-
ctx.throw(
|
|
134
|
+
ctx.throw(
|
|
135
|
+
JSON.stringify(reply("e", { error: bodyValidate.requires })),
|
|
136
|
+
412
|
|
137
|
+
);
|
|
129
138
|
}
|
|
130
139
|
|
|
131
140
|
// access validation
|
|
@@ -142,7 +151,7 @@ dataProvider.post("/find-one", async (ctx) => {
|
|
|
142
151
|
let collection = service.getCollection(body.database, body.collection);
|
|
143
152
|
if (collection == null) {
|
|
144
153
|
ctx.throw(
|
|
145
|
-
JSON.stringify(reply("e", {
|
|
154
|
+
JSON.stringify(reply("e", { error: "wrong database or collection" })),
|
|
146
155
|
412
|
|
147
156
|
);
|
|
148
157
|
}
|
|
@@ -194,7 +203,10 @@ dataProvider.post("/count", async (ctx) => {
|
|
|
194
203
|
|
|
195
204
|
// fields validation
|
|
196
205
|
if (!bodyValidate.isValid) {
|
|
197
|
-
ctx.throw(
|
|
206
|
+
ctx.throw(
|
|
207
|
+
JSON.stringify(reply("e", { error: bodyValidate.requires })),
|
|
208
|
+
412
|
|
209
|
+
);
|
|
198
210
|
}
|
|
199
211
|
|
|
200
212
|
// access validation
|
|
@@ -211,7 +223,7 @@ dataProvider.post("/count", async (ctx) => {
|
|
|
211
223
|
let collection = service.getCollection(body.database, body.collection);
|
|
212
224
|
if (collection == null) {
|
|
213
225
|
ctx.throw(
|
|
214
|
-
JSON.stringify(reply("e", {
|
|
226
|
+
JSON.stringify(reply("e", { error: "wrong database or collection" })),
|
|
215
227
|
412
|
|
216
228
|
);
|
|
217
229
|
}
|
|
@@ -241,7 +253,10 @@ dataProvider.post("/update-one", async (ctx) => {
|
|
|
241
253
|
|
|
242
254
|
// fields validation
|
|
243
255
|
if (!bodyValidate.isValid) {
|
|
244
|
-
ctx.throw(
|
|
256
|
+
ctx.throw(
|
|
257
|
+
JSON.stringify(reply("e", { error: bodyValidate.requires })),
|
|
258
|
+
412
|
|
259
|
+
);
|
|
245
260
|
}
|
|
246
261
|
|
|
247
262
|
// access validation
|
|
@@ -258,7 +273,7 @@ dataProvider.post("/update-one", async (ctx) => {
|
|
|
258
273
|
let collection = service.getCollection(body.database, body.collection);
|
|
259
274
|
if (collection == null) {
|
|
260
275
|
ctx.throw(
|
|
261
|
-
JSON.stringify(reply("e", {
|
|
276
|
+
JSON.stringify(reply("e", { error: "wrong database or collection" })),
|
|
262
277
|
412
|
|
263
278
|
);
|
|
264
279
|
}
|
|
@@ -291,7 +306,10 @@ dataProvider.post("/insert-one", async (ctx) => {
|
|
|
291
306
|
|
|
292
307
|
// fields validation
|
|
293
308
|
if (!bodyValidate.isValid) {
|
|
294
|
-
ctx.throw(
|
|
309
|
+
ctx.throw(
|
|
310
|
+
JSON.stringify(reply("e", { error: bodyValidate.requires })),
|
|
311
|
+
412
|
|
312
|
+
);
|
|
295
313
|
}
|
|
296
314
|
|
|
297
315
|
// access validation
|
|
@@ -312,7 +330,7 @@ dataProvider.post("/insert-one", async (ctx) => {
|
|
|
312
330
|
let collection = service.getCollection(body.database, body.collection);
|
|
313
331
|
if (collection == null) {
|
|
314
332
|
ctx.throw(
|
|
315
|
-
JSON.stringify(reply("e", {
|
|
333
|
+
JSON.stringify(reply("e", { error: "wrong database or collection" })),
|
|
316
334
|
412
|
|
317
335
|
);
|
|
318
336
|
}
|
|
@@ -341,7 +359,10 @@ dataProvider.post("/remove-one", async (ctx) => {
|
|
|
341
359
|
|
|
342
360
|
// fields validation
|
|
343
361
|
if (!bodyValidate.isValid) {
|
|
344
|
-
ctx.throw(
|
|
362
|
+
ctx.throw(
|
|
363
|
+
JSON.stringify(reply("e", { error: bodyValidate.requires })),
|
|
364
|
+
412
|
|
365
|
+
);
|
|
345
366
|
}
|
|
346
367
|
|
|
347
368
|
// access validation
|
|
@@ -358,7 +379,7 @@ dataProvider.post("/remove-one", async (ctx) => {
|
|
|
358
379
|
let collection = service.getCollection(body.database, body.collection);
|
|
359
380
|
if (collection == null) {
|
|
360
381
|
ctx.throw(
|
|
361
|
-
JSON.stringify(reply("e", {
|
|
382
|
+
JSON.stringify(reply("e", { error: "wrong database or collection" })),
|
|
362
383
|
412
|
|
363
384
|
);
|
|
364
385
|
}
|
|
@@ -391,7 +412,10 @@ dataProvider.post("/aggregate", async (ctx) => {
|
|
|
391
412
|
|
|
392
413
|
// fields validation
|
|
393
414
|
if (!bodyValidate.isValid) {
|
|
394
|
-
ctx.throw(
|
|
415
|
+
ctx.throw(
|
|
416
|
+
JSON.stringify(reply("e", { error: bodyValidate.requires })),
|
|
417
|
+
412
|
|
418
|
+
);
|
|
395
419
|
}
|
|
396
420
|
|
|
397
421
|
// access validation
|
|
@@ -408,7 +432,7 @@ dataProvider.post("/aggregate", async (ctx) => {
|
|
|
408
432
|
let collection = service.getCollection(body.database, body.collection);
|
|
409
433
|
if (collection == null) {
|
|
410
434
|
ctx.throw(
|
|
411
|
-
JSON.stringify(reply("e", {
|
|
435
|
+
JSON.stringify(reply("e", { error: "wrong database or collection" })),
|
|
412
436
|
412
|
|
413
437
|
);
|
|
414
438
|
}
|
|
@@ -438,7 +462,10 @@ dataProvider.post("/findByIds", async (ctx, next) => {
|
|
|
438
462
|
|
|
439
463
|
// fields validation
|
|
440
464
|
if (!bodyValidate.isValid) {
|
|
441
|
-
ctx.throw(
|
|
465
|
+
ctx.throw(
|
|
466
|
+
JSON.stringify(reply("e", { error: bodyValidate.requires })),
|
|
467
|
+
412
|
|
468
|
+
);
|
|
442
469
|
}
|
|
443
470
|
|
|
444
471
|
// access validation
|
|
@@ -455,7 +482,7 @@ dataProvider.post("/findByIds", async (ctx, next) => {
|
|
|
455
482
|
let collection = service.getCollection(body.database, body.collection);
|
|
456
483
|
if (collection == null) {
|
|
457
484
|
ctx.throw(
|
|
458
|
-
JSON.stringify(reply("e", {
|
|
485
|
+
JSON.stringify(reply("e", { error: "wrong database or collection" })),
|
|
459
486
|
412
|
|
460
487
|
);
|
|
461
488
|
}
|
|
@@ -13,7 +13,10 @@ functionRouter.use("/", middleware.auth, async (ctx, next) => {
|
|
|
13
13
|
|
|
14
14
|
// fields validation
|
|
15
15
|
if (!bodyValidated.isValid) {
|
|
16
|
-
ctx.throw(
|
|
16
|
+
ctx.throw(
|
|
17
|
+
412,
|
|
18
|
+
JSON.stringify(reply("e", { error: bodyValidated.requires }))
|
|
19
|
+
);
|
|
17
20
|
}
|
|
18
21
|
|
|
19
22
|
await next();
|
|
@@ -26,7 +29,7 @@ functionRouter.post(`/run`, middleware.auth, async (ctx) => {
|
|
|
26
29
|
const result = await service.runFunction(name, args, ctx.state.user);
|
|
27
30
|
ctx.body = JSON.stringify(reply("s", { data: result }));
|
|
28
31
|
} catch (e) {
|
|
29
|
-
ctx.throw(400, JSON.stringify(reply("e", {
|
|
32
|
+
ctx.throw(400, JSON.stringify(reply("e", { error: e.message })));
|
|
30
33
|
}
|
|
31
34
|
});
|
|
32
35
|
|