gg-express 1.0.83 → 1.0.86
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/v2/generateStaticRouteFileV2.js +10 -6
- package/dist/v2/output/apiConnector_hotel_v2.js +1 -1
- package/dist/v2/output/staticRouteInterface_hotel_v2.d.ts +2 -6
- package/dist/v2/run_v2.test.js +18 -14
- package/package.json +1 -1
- package/src/v2/generateStaticRouteFileV2.ts +9 -6
- package/src/v2/output/apiConnector_hotel_v2.ts +2 -1
- package/src/v2/output/staticRouteInterface_hotel_v2.ts +23 -31
- package/src/v2/run_v2.test.ts +19 -13
|
@@ -50,7 +50,10 @@ function parentInputToCode(data) {
|
|
|
50
50
|
const recusiveResult = recursiveExtract(target[keyName], keyName);
|
|
51
51
|
tempResult.push(recusiveResult);
|
|
52
52
|
}
|
|
53
|
-
|
|
53
|
+
if (parentKeyName === "root")
|
|
54
|
+
result = ` { ${tempResult.join(",")} } `;
|
|
55
|
+
else
|
|
56
|
+
result = `${result} \n ${parentKeyName} : { ${tempResult.join(",")} }`;
|
|
54
57
|
}
|
|
55
58
|
// check array ---------------------------
|
|
56
59
|
else if (Array.isArray(target)) {
|
|
@@ -70,8 +73,8 @@ function parentInputToCode(data) {
|
|
|
70
73
|
}
|
|
71
74
|
return `${result}`;
|
|
72
75
|
};
|
|
73
|
-
const result = recursiveExtract(data, "
|
|
74
|
-
return `${result}
|
|
76
|
+
const result = recursiveExtract(data, "root");
|
|
77
|
+
return `${result}`;
|
|
75
78
|
}
|
|
76
79
|
function generateStaticRouteFileV2(appName, data) {
|
|
77
80
|
const interfaceName = `staticRouteInterface_${appName}_v2`;
|
|
@@ -80,10 +83,11 @@ function generateStaticRouteFileV2(appName, data) {
|
|
|
80
83
|
return keyName
|
|
81
84
|
.map((keyName) => `
|
|
82
85
|
"${keyName}" : {
|
|
83
|
-
requireParams :
|
|
84
|
-
responseStructure : {
|
|
86
|
+
requireParams : ${data[keyName].requireParams} ,
|
|
87
|
+
responseStructure : {
|
|
88
|
+
data : ${data[keyName].responseStructure},
|
|
85
89
|
status: "SUCCESS" | "ERROR",
|
|
86
|
-
message: string }
|
|
90
|
+
message: string }
|
|
87
91
|
}`)
|
|
88
92
|
.join(", ");
|
|
89
93
|
};
|
|
@@ -2,9 +2,7 @@ export interface staticRouteInterface_hotel_v2 {
|
|
|
2
2
|
get: {
|
|
3
3
|
"/api/hotel/users/id": {
|
|
4
4
|
requireParams: {
|
|
5
|
-
|
|
6
|
-
id: number;
|
|
7
|
-
};
|
|
5
|
+
id: number;
|
|
8
6
|
};
|
|
9
7
|
responseStructure: {
|
|
10
8
|
data: {
|
|
@@ -21,9 +19,7 @@ export interface staticRouteInterface_hotel_v2 {
|
|
|
21
19
|
post: {
|
|
22
20
|
"/api/hotel/booking/id": {
|
|
23
21
|
requireParams: {
|
|
24
|
-
|
|
25
|
-
id: number;
|
|
26
|
-
};
|
|
22
|
+
id: number;
|
|
27
23
|
};
|
|
28
24
|
responseStructure: {
|
|
29
25
|
data: {
|
package/dist/v2/run_v2.test.js
CHANGED
|
@@ -15,8 +15,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
15
15
|
const express_1 = __importDefault(require("express"));
|
|
16
16
|
const GGExpressV2_1 = __importDefault(require("./GGExpressV2"));
|
|
17
17
|
const typeResolver_1 = require("./typeResolver");
|
|
18
|
-
const apiConnector_hotel_v2_1 = require("./output/apiConnector_hotel_v2");
|
|
19
|
-
// import { GGApi_v2 } from "./output/apiConnector_hotel_v2"
|
|
20
18
|
function run() {
|
|
21
19
|
const app = (0, express_1.default)();
|
|
22
20
|
const ggapp = new GGExpressV2_1.default(app, "hotel", ["./output"]);
|
|
@@ -31,8 +29,8 @@ function run() {
|
|
|
31
29
|
}),
|
|
32
30
|
},
|
|
33
31
|
}, (req, res, next) => {
|
|
34
|
-
console.log(req.query);
|
|
35
|
-
req.query.id;
|
|
32
|
+
console.log("req.query", req.query);
|
|
33
|
+
console.log("req.query.id", req.query.id);
|
|
36
34
|
return res.json({
|
|
37
35
|
message: "",
|
|
38
36
|
status: "SUCCESS",
|
|
@@ -50,6 +48,7 @@ function run() {
|
|
|
50
48
|
},
|
|
51
49
|
},
|
|
52
50
|
}, (req, res, next) => {
|
|
51
|
+
req.body.id;
|
|
53
52
|
return res.json({
|
|
54
53
|
message: "",
|
|
55
54
|
status: "SUCCESS",
|
|
@@ -64,15 +63,20 @@ function run() {
|
|
|
64
63
|
app.listen(3002, () => __awaiter(this, void 0, void 0, function* () {
|
|
65
64
|
yield ggapp.generateAPIFiles();
|
|
66
65
|
console.log("done");
|
|
67
|
-
process.exit(0)
|
|
66
|
+
// process.exit(0)
|
|
68
67
|
}));
|
|
69
68
|
}
|
|
70
|
-
run()
|
|
71
|
-
|
|
72
|
-
x
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
69
|
+
// run()
|
|
70
|
+
// setTimeout(() => {
|
|
71
|
+
// const x = new GGApi_v2()
|
|
72
|
+
// //@ts-ignore
|
|
73
|
+
// x.get("http://localhost:3002/api/hotel/users/id", {
|
|
74
|
+
// id: 1,
|
|
75
|
+
// })
|
|
76
|
+
// .then((response) => {
|
|
77
|
+
// console.log("response", response)
|
|
78
|
+
// })
|
|
79
|
+
// .catch((error) => {
|
|
80
|
+
// console.error("fetch error")
|
|
81
|
+
// })
|
|
82
|
+
// }, 3000)
|
package/package.json
CHANGED
|
@@ -72,7 +72,9 @@ function parentInputToCode(data: InputParent) {
|
|
|
72
72
|
const recusiveResult = recursiveExtract(target[keyName], keyName)
|
|
73
73
|
tempResult.push(recusiveResult)
|
|
74
74
|
}
|
|
75
|
-
|
|
75
|
+
if (parentKeyName === "root") result = ` { ${tempResult.join(",")} } `
|
|
76
|
+
else
|
|
77
|
+
result = `${result} \n ${parentKeyName} : { ${tempResult.join(",")} }`
|
|
76
78
|
}
|
|
77
79
|
|
|
78
80
|
// check array ---------------------------
|
|
@@ -95,8 +97,8 @@ function parentInputToCode(data: InputParent) {
|
|
|
95
97
|
}
|
|
96
98
|
return `${result}`
|
|
97
99
|
}
|
|
98
|
-
const result = recursiveExtract(data, "
|
|
99
|
-
return `${result}
|
|
100
|
+
const result = recursiveExtract(data, "root")
|
|
101
|
+
return `${result}`
|
|
100
102
|
}
|
|
101
103
|
export function generateStaticRouteFileV2(appName: string, data: routeList[]) {
|
|
102
104
|
const interfaceName = `staticRouteInterface_${appName}_v2`
|
|
@@ -106,10 +108,11 @@ export function generateStaticRouteFileV2(appName: string, data: routeList[]) {
|
|
|
106
108
|
.map(
|
|
107
109
|
(keyName) => `
|
|
108
110
|
"${keyName}" : {
|
|
109
|
-
requireParams :
|
|
110
|
-
responseStructure : {
|
|
111
|
+
requireParams : ${data[keyName].requireParams} ,
|
|
112
|
+
responseStructure : {
|
|
113
|
+
data : ${data[keyName].responseStructure},
|
|
111
114
|
status: "SUCCESS" | "ERROR",
|
|
112
|
-
message: string }
|
|
115
|
+
message: string }
|
|
113
116
|
}`
|
|
114
117
|
)
|
|
115
118
|
.join(", ")
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
|
|
1
2
|
import axios from "axios"
|
|
2
3
|
import { staticRouteInterface_hotel_v2 } from "./staticRouteInterface_hotel_v2"
|
|
3
4
|
|
|
@@ -10,7 +11,7 @@ export class GGApi_v2 {
|
|
|
10
11
|
): Promise<staticRouteInterface_hotel_v2["get"][T]["responseStructure"]> {
|
|
11
12
|
return new Promise((resolve, reject) => {
|
|
12
13
|
axios
|
|
13
|
-
.get(url as string, { params:
|
|
14
|
+
.get(url as string, { params: requireParams })
|
|
14
15
|
.then((response) => {
|
|
15
16
|
resolve(response.data)
|
|
16
17
|
})
|
|
@@ -1,32 +1,24 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
1
|
+
|
|
2
|
+
export interface staticRouteInterface_hotel_v2 {
|
|
3
|
+
get : {
|
|
4
|
+
"/api/hotel/users/id" : {
|
|
5
|
+
requireParams : { id : number } ,
|
|
6
|
+
responseStructure : {
|
|
7
|
+
data : {
|
|
8
|
+
userData : { id : number,name : string }[] } ,
|
|
9
|
+
status: "SUCCESS" | "ERROR",
|
|
10
|
+
message: string }
|
|
11
|
+
} },
|
|
12
|
+
post : {
|
|
13
|
+
"/api/hotel/booking/id" : {
|
|
14
|
+
requireParams : { id : number } ,
|
|
15
|
+
responseStructure : {
|
|
16
|
+
data : {
|
|
17
|
+
bookingData : { id : number,roomNumber : string } } ,
|
|
18
|
+
status: "SUCCESS" | "ERROR",
|
|
19
|
+
message: string }
|
|
20
|
+
} },
|
|
21
|
+
put : { },
|
|
22
|
+
delete : { },
|
|
15
23
|
}
|
|
16
|
-
|
|
17
|
-
"/api/hotel/booking/id": {
|
|
18
|
-
requireParams: {
|
|
19
|
-
data: { id: number }
|
|
20
|
-
}
|
|
21
|
-
responseStructure: {
|
|
22
|
-
data: {
|
|
23
|
-
bookingData: { id: number; roomNumber: string }
|
|
24
|
-
}
|
|
25
|
-
status: "SUCCESS" | "ERROR"
|
|
26
|
-
message: string
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
put: {}
|
|
31
|
-
delete: {}
|
|
32
|
-
}
|
|
24
|
+
|
package/src/v2/run_v2.test.ts
CHANGED
|
@@ -2,7 +2,6 @@ import express, { Express } from "express"
|
|
|
2
2
|
import GGExpressV2 from "./GGExpressV2"
|
|
3
3
|
import { toArray } from "./typeResolver"
|
|
4
4
|
import { GGApi_v2 } from "./output/apiConnector_hotel_v2"
|
|
5
|
-
// import { GGApi_v2 } from "./output/apiConnector_hotel_v2"
|
|
6
5
|
function run() {
|
|
7
6
|
const app = express()
|
|
8
7
|
const ggapp = new GGExpressV2<"hotel">(app, "hotel", ["./output"])
|
|
@@ -20,8 +19,9 @@ function run() {
|
|
|
20
19
|
},
|
|
21
20
|
},
|
|
22
21
|
(req, res, next) => {
|
|
23
|
-
console.log(req.query)
|
|
24
|
-
req.query.id
|
|
22
|
+
console.log("req.query", req.query)
|
|
23
|
+
console.log("req.query.id", req.query.id)
|
|
24
|
+
|
|
25
25
|
return res.json({
|
|
26
26
|
message: "",
|
|
27
27
|
status: "SUCCESS",
|
|
@@ -43,6 +43,7 @@ function run() {
|
|
|
43
43
|
},
|
|
44
44
|
},
|
|
45
45
|
(req, res, next) => {
|
|
46
|
+
req.body.id
|
|
46
47
|
return res.json({
|
|
47
48
|
message: "",
|
|
48
49
|
status: "SUCCESS",
|
|
@@ -59,16 +60,21 @@ function run() {
|
|
|
59
60
|
app.listen(3002, async () => {
|
|
60
61
|
await ggapp.generateAPIFiles()
|
|
61
62
|
console.log("done")
|
|
62
|
-
process.exit(0)
|
|
63
|
+
// process.exit(0)
|
|
63
64
|
})
|
|
64
65
|
}
|
|
65
|
-
run()
|
|
66
|
+
// run()
|
|
66
67
|
|
|
67
|
-
|
|
68
|
-
x
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
68
|
+
// setTimeout(() => {
|
|
69
|
+
// const x = new GGApi_v2()
|
|
70
|
+
// //@ts-ignore
|
|
71
|
+
// x.get("http://localhost:3002/api/hotel/users/id", {
|
|
72
|
+
// id: 1,
|
|
73
|
+
// })
|
|
74
|
+
// .then((response) => {
|
|
75
|
+
// console.log("response", response)
|
|
76
|
+
// })
|
|
77
|
+
// .catch((error) => {
|
|
78
|
+
// console.error("fetch error")
|
|
79
|
+
// })
|
|
80
|
+
// }, 3000)
|