very-express 0.5.18 → 0.5.20
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/index.js +144 -144
- package/dist/templates/_projectSettings/env +2 -1
- package/dist/templates/_utils/common.ts +15 -8
- package/package.json +1 -1
|
@@ -20,22 +20,21 @@ export function loadYaml(yamlFilePath: string) {
|
|
|
20
20
|
* @error may throw an error if the fieldsString is not a valid JSON
|
|
21
21
|
*/
|
|
22
22
|
export function parseFieldsSelect(req: Request) : ({ [key: string]: number } | undefined) {
|
|
23
|
-
|
|
24
23
|
let _selectRaw: string[] = [];
|
|
25
|
-
|
|
24
|
+
|
|
25
|
+
if(!req.query._select && !req.body._select) {
|
|
26
|
+
return undefined;
|
|
27
|
+
}
|
|
26
28
|
|
|
27
29
|
if(req.method === "GET") {
|
|
28
30
|
const selectString = String(req.query._select);
|
|
29
|
-
|
|
30
|
-
if (typeof selectString === "undefined" || selectString === "") {
|
|
31
|
-
return undefined;
|
|
32
|
-
}
|
|
33
31
|
_selectRaw = JSON.parse(selectString);
|
|
34
32
|
}
|
|
35
33
|
else{
|
|
36
34
|
_selectRaw = req.body._select;
|
|
37
35
|
}
|
|
38
36
|
|
|
37
|
+
const ErrorDataType = new VexResponseError(400, response.code.err_validation, "Invalid field \"_select\", only json array of string accepted");
|
|
39
38
|
if (!Array.isArray(_selectRaw)) {
|
|
40
39
|
throw ErrorDataType;
|
|
41
40
|
}
|
|
@@ -56,9 +55,11 @@ export function parseFieldsSelect(req: Request) : ({ [key: string]: number } | u
|
|
|
56
55
|
}
|
|
57
56
|
|
|
58
57
|
export function parseCollectionJoin(req: Request, availablePopulateOptions:{[key:string]: string}) : { [key: string]: string } | undefined {
|
|
59
|
-
|
|
58
|
+
if(!req.query._select && !req.body._select) {
|
|
59
|
+
return undefined;
|
|
60
|
+
}
|
|
61
|
+
|
|
60
62
|
let _joinRaw: string[] = [];
|
|
61
|
-
const ErrorDataType = new VexResponseError(400, response.code.err_validation, "Invalid field \"_join\", only json array accepted");
|
|
62
63
|
|
|
63
64
|
if(req.method === "GET") {
|
|
64
65
|
const rawString = String(req.query._join);
|
|
@@ -71,9 +72,15 @@ export function parseCollectionJoin(req: Request, availablePopulateOptions:{[key
|
|
|
71
72
|
_joinRaw = req.body._join;
|
|
72
73
|
}
|
|
73
74
|
|
|
75
|
+
const ErrorDataType = new VexResponseError(400, response.code.err_validation, "Invalid field \"_join\", only json array of string accepted");
|
|
74
76
|
if (!Array.isArray(_joinRaw)) {
|
|
75
77
|
throw ErrorDataType;
|
|
76
78
|
}
|
|
79
|
+
for (let i = 0; i < _joinRaw.length; i++) {
|
|
80
|
+
if (typeof _joinRaw[i] !== "string") {
|
|
81
|
+
throw ErrorDataType;
|
|
82
|
+
}
|
|
83
|
+
}
|
|
77
84
|
|
|
78
85
|
// switch joinArr's item to populate options
|
|
79
86
|
const populateOptions: {[key:string]:any} = [];
|