gg-express 1.0.74 → 1.0.79
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/.vscode/settings.json +3 -0
- package/dist/GGExpress.js +16 -5
- package/dist/helperFunction.d.ts +1 -0
- package/dist/helperFunction.js +6 -0
- package/dist/staticRouteInterface_hotel.d.ts +46 -0
- package/package.json +1 -1
- package/src/GGExpress.ts +16 -6
- package/src/helperFunction.ts +3 -0
- package/src/staticRouteInterface_hotel.ts +24 -0
package/dist/GGExpress.js
CHANGED
|
@@ -15,6 +15,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
15
15
|
const chalk_1 = __importDefault(require("chalk"));
|
|
16
16
|
const fs_1 = __importDefault(require("fs"));
|
|
17
17
|
const path_1 = __importDefault(require("path"));
|
|
18
|
+
const helperFunction_1 = require("./helperFunction");
|
|
18
19
|
const myExpressRouteList = [];
|
|
19
20
|
class GGExpress {
|
|
20
21
|
constructor(app, appName, outputPath) {
|
|
@@ -23,11 +24,20 @@ class GGExpress {
|
|
|
23
24
|
this.appName = appName;
|
|
24
25
|
}
|
|
25
26
|
rootMethod(method, url, options, ...middlewares) {
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
27
|
+
let tempURL;
|
|
28
|
+
if (Array.isArray(url)) {
|
|
29
|
+
tempURL = url;
|
|
30
|
+
}
|
|
31
|
+
else {
|
|
32
|
+
tempURL = [url];
|
|
33
|
+
}
|
|
34
|
+
tempURL.map((url) => {
|
|
35
|
+
myExpressRouteList.push({
|
|
36
|
+
method: method,
|
|
37
|
+
url: url,
|
|
38
|
+
requireParams: options.requireParams,
|
|
39
|
+
responseStructure: options.responseStructure,
|
|
40
|
+
});
|
|
31
41
|
});
|
|
32
42
|
return this.express[method](url, (req, res, next) => {
|
|
33
43
|
return next();
|
|
@@ -157,6 +167,7 @@ class GGExpress {
|
|
|
157
167
|
else {
|
|
158
168
|
tempURL = [row.url];
|
|
159
169
|
}
|
|
170
|
+
tempURL = (0, helperFunction_1.removeDuplicates)(tempURL);
|
|
160
171
|
return tempURL
|
|
161
172
|
.map((url) => {
|
|
162
173
|
return ` "${url}" : {
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function removeDuplicates(arr: string[]): string[];
|
|
@@ -23,6 +23,52 @@ export interface staticRouteInterface_hotel {
|
|
|
23
23
|
}[];
|
|
24
24
|
};
|
|
25
25
|
};
|
|
26
|
+
"/api/seed/memo/id": {
|
|
27
|
+
requireParams: {
|
|
28
|
+
parameter: {
|
|
29
|
+
files: string[];
|
|
30
|
+
};
|
|
31
|
+
data: {
|
|
32
|
+
id: number;
|
|
33
|
+
name: "A" | "B";
|
|
34
|
+
}[];
|
|
35
|
+
};
|
|
36
|
+
responseStructure: {
|
|
37
|
+
status: "SUCCESS" | "ERROR";
|
|
38
|
+
message: string;
|
|
39
|
+
parameter: {
|
|
40
|
+
numberOfPeople: number;
|
|
41
|
+
itemName: string;
|
|
42
|
+
};
|
|
43
|
+
data: {
|
|
44
|
+
id: number;
|
|
45
|
+
name: string;
|
|
46
|
+
}[];
|
|
47
|
+
};
|
|
48
|
+
};
|
|
49
|
+
"/api/hotel/memo/id": {
|
|
50
|
+
requireParams: {
|
|
51
|
+
parameter: {
|
|
52
|
+
files: string[];
|
|
53
|
+
};
|
|
54
|
+
data: {
|
|
55
|
+
id: number;
|
|
56
|
+
name: "A" | "B";
|
|
57
|
+
}[];
|
|
58
|
+
};
|
|
59
|
+
responseStructure: {
|
|
60
|
+
status: "SUCCESS" | "ERROR";
|
|
61
|
+
message: string;
|
|
62
|
+
parameter: {
|
|
63
|
+
numberOfPeople: number;
|
|
64
|
+
itemName: string;
|
|
65
|
+
};
|
|
66
|
+
data: {
|
|
67
|
+
id: number;
|
|
68
|
+
name: string;
|
|
69
|
+
}[];
|
|
70
|
+
};
|
|
71
|
+
};
|
|
26
72
|
};
|
|
27
73
|
post: {
|
|
28
74
|
"/api/hotel/item": {
|
package/package.json
CHANGED
package/src/GGExpress.ts
CHANGED
|
@@ -3,6 +3,7 @@ import { NextFunction, Request, Response } from "express"
|
|
|
3
3
|
import Express from "express-serve-static-core"
|
|
4
4
|
import fs from "fs"
|
|
5
5
|
import path from "path"
|
|
6
|
+
import { removeDuplicates } from "./helperFunction"
|
|
6
7
|
|
|
7
8
|
type Unarray<T> = T extends (infer U)[] ? U : T
|
|
8
9
|
type AsConstArray<T extends readonly any[]> = [...T]
|
|
@@ -106,7 +107,7 @@ type MyResponse<
|
|
|
106
107
|
|
|
107
108
|
const myExpressRouteList: {
|
|
108
109
|
method: "get" | "post" | "put" | "delete"
|
|
109
|
-
url: string
|
|
110
|
+
url: string
|
|
110
111
|
requireParams: requireParamsStructure
|
|
111
112
|
responseStructure: responseStructure
|
|
112
113
|
}[] = []
|
|
@@ -147,11 +148,19 @@ export default class GGExpress<appName extends string> {
|
|
|
147
148
|
) => any
|
|
148
149
|
>
|
|
149
150
|
) {
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
151
|
+
let tempURL
|
|
152
|
+
if (Array.isArray(url)) {
|
|
153
|
+
tempURL = url
|
|
154
|
+
} else {
|
|
155
|
+
tempURL = [url]
|
|
156
|
+
}
|
|
157
|
+
tempURL.map((url) => {
|
|
158
|
+
myExpressRouteList.push({
|
|
159
|
+
method: method,
|
|
160
|
+
url: url,
|
|
161
|
+
requireParams: options.requireParams,
|
|
162
|
+
responseStructure: options.responseStructure,
|
|
163
|
+
})
|
|
155
164
|
})
|
|
156
165
|
|
|
157
166
|
return this.express[method](
|
|
@@ -395,6 +404,7 @@ export default class GGExpress<appName extends string> {
|
|
|
395
404
|
} else {
|
|
396
405
|
tempURL = [row.url]
|
|
397
406
|
}
|
|
407
|
+
tempURL = removeDuplicates(tempURL)
|
|
398
408
|
return tempURL
|
|
399
409
|
.map((url) => {
|
|
400
410
|
return ` "${url}" : {
|
|
@@ -12,6 +12,30 @@ export interface staticRouteInterface_hotel {
|
|
|
12
12
|
data: { id: number; name: string }[]
|
|
13
13
|
}
|
|
14
14
|
}
|
|
15
|
+
"/api/seed/memo/id": {
|
|
16
|
+
requireParams: {
|
|
17
|
+
parameter: { files: string[] }
|
|
18
|
+
data: { id: number; name: "A" | "B" }[]
|
|
19
|
+
}
|
|
20
|
+
responseStructure: {
|
|
21
|
+
status: "SUCCESS" | "ERROR"
|
|
22
|
+
message: string
|
|
23
|
+
parameter: { numberOfPeople: number; itemName: string }
|
|
24
|
+
data: { id: number; name: string }[]
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
"/api/hotel/memo/id": {
|
|
28
|
+
requireParams: {
|
|
29
|
+
parameter: { files: string[] }
|
|
30
|
+
data: { id: number; name: "A" | "B" }[]
|
|
31
|
+
}
|
|
32
|
+
responseStructure: {
|
|
33
|
+
status: "SUCCESS" | "ERROR"
|
|
34
|
+
message: string
|
|
35
|
+
parameter: { numberOfPeople: number; itemName: string }
|
|
36
|
+
data: { id: number; name: string }[]
|
|
37
|
+
}
|
|
38
|
+
}
|
|
15
39
|
}
|
|
16
40
|
post: {
|
|
17
41
|
"/api/hotel/item": {
|