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.
@@ -1,4 +1,5 @@
1
- APP_HOST=http://localhost:3000
1
+ APP_HOST=http://localhost
2
+ APP_PORT=3000
2
3
  MONGODB_URI=mongodb://localhost:27017/veryExpressDB
3
4
 
4
5
  LOGIN_SUCCESS_REDIRECT_PATH=/logincallback
@@ -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
- const ErrorDataType = new VexResponseError(400, response.code.err_validation, "Invalid field \"_select\", only json array accepted");
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} = [];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "very-express",
3
- "version": "0.5.18",
3
+ "version": "0.5.20",
4
4
  "description": "based on json schema and openapi, generate Express RestApi server with mongoDb ",
5
5
  "author": "Justin26l",
6
6
  "license": "MIT",