gg-express 1.0.135 → 1.0.136
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/v3/GGExpressV3.d.ts +7 -4
- package/dist/v3/generateStaticRouteFileV3.d.ts +2 -2
- package/dist/v3/generateStaticRouteFileV3.js +2 -2
- package/dist/v3/output/apiConnector_hotel_v3.js +6 -4
- package/dist/v3/output/staticRouteInterface_hotel_v3.d.ts +11 -6
- package/dist/v3/run_v3.test.js +20 -13
- package/package.json +1 -1
- package/src/v3/GGExpressV3.ts +9 -5
- package/src/v3/generateStaticRouteFileV3.ts +4 -4
- package/src/v3/output/apiConnector_hotel_v3.ts +12 -11
- package/src/v3/output/staticRouteInterface_hotel_v3.ts +37 -33
- package/src/v3/run_v3.test.ts +19 -13
package/dist/v3/GGExpressV3.d.ts
CHANGED
|
@@ -4,6 +4,9 @@ import z from "zod";
|
|
|
4
4
|
export type Method = "get" | "post" | "put" | "delete";
|
|
5
5
|
type MyQueryRequest<RQ extends z.ZodTypeAny> = Request<{}, {}, {}, MyRequestStructure<RQ>, {}>;
|
|
6
6
|
type MyBodyRequest<RQ extends z.ZodTypeAny> = Request<{}, {}, MyRequestStructure<RQ>, {}, {}>;
|
|
7
|
+
export type RequestStructure<RQ extends z.ZodTypeAny> = {
|
|
8
|
+
data: RQ;
|
|
9
|
+
};
|
|
7
10
|
type MyRequestStructure<RQ extends z.ZodTypeAny> = {
|
|
8
11
|
data: z.infer<RQ>;
|
|
9
12
|
};
|
|
@@ -15,19 +18,19 @@ export default class GGExpressV3<appName extends string, urlPrefix extends strin
|
|
|
15
18
|
constructor(app: Express.Express, appName: appName, outputPath: string[]);
|
|
16
19
|
private rootMethod;
|
|
17
20
|
get<RQ extends z.ZodTypeAny, RS extends z.ZodTypeAny>(url: `${urlPrefix}/${appName}/${string}` | `${urlPrefix}/${appName}/${string}`[], options: {
|
|
18
|
-
requireParams: RQ
|
|
21
|
+
requireParams: RequestStructure<RQ>;
|
|
19
22
|
responseStructure: RS;
|
|
20
23
|
}, ...middlewares: Array<(req: MyQueryRequest<RQ>, res: MyResponse<RS>, next: NextFunction) => void | Promise<void>>): Express.Express;
|
|
21
24
|
post<RQ extends z.ZodTypeAny, RS extends z.ZodTypeAny>(url: `${urlPrefix}/${appName}/${string}` | `${urlPrefix}/${appName}/${string}`[], options: {
|
|
22
|
-
requireParams: RQ
|
|
25
|
+
requireParams: RequestStructure<RQ>;
|
|
23
26
|
responseStructure: RS;
|
|
24
27
|
}, ...middlewares: Array<(req: MyBodyRequest<RQ>, res: MyResponse<RS>, next: NextFunction) => void | Promise<void>>): Express.Express;
|
|
25
28
|
put<RQ extends z.ZodTypeAny, RS extends z.ZodTypeAny>(url: `${urlPrefix}/${appName}/${string}` | `${urlPrefix}/${appName}/${string}`[], options: {
|
|
26
|
-
requireParams: RQ
|
|
29
|
+
requireParams: RequestStructure<RQ>;
|
|
27
30
|
responseStructure: RS;
|
|
28
31
|
}, ...middlewares: Array<(req: MyBodyRequest<RQ>, res: MyResponse<RS>, next: NextFunction) => void | Promise<void>>): Express.Express;
|
|
29
32
|
delete<RQ extends z.ZodTypeAny, RS extends z.ZodTypeAny>(url: `${urlPrefix}/${appName}/${string}` | `${urlPrefix}/${appName}/${string}`[], options: {
|
|
30
|
-
requireParams: RQ
|
|
33
|
+
requireParams: RequestStructure<RQ>;
|
|
31
34
|
responseStructure: RS;
|
|
32
35
|
}, ...middlewares: Array<(req: MyBodyRequest<RQ>, res: MyResponse<RS>, next: NextFunction) => void | Promise<void>>): Express.Express;
|
|
33
36
|
generateAPIFiles(): Promise<void>;
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import z from "zod";
|
|
2
|
-
import { Method } from "./GGExpressV3";
|
|
2
|
+
import { Method, RequestStructure } from "./GGExpressV3";
|
|
3
3
|
import ts from "typescript";
|
|
4
4
|
export declare function typeNodeToString(node: ts.TypeNode): string;
|
|
5
5
|
export type routeListV3 = {
|
|
6
6
|
method: Method;
|
|
7
7
|
url: string;
|
|
8
|
-
requireParams: z.ZodTypeAny
|
|
8
|
+
requireParams: RequestStructure<z.ZodTypeAny>;
|
|
9
9
|
responseStructure: z.ZodTypeAny;
|
|
10
10
|
};
|
|
11
11
|
export declare function generateStaticRouteFileV3(appName: string, data: routeListV3[]): string;
|
|
@@ -25,7 +25,7 @@ function prepareExportInterfaceData(data) {
|
|
|
25
25
|
function extract(allData, prepareRoute) {
|
|
26
26
|
for (const route of allData) {
|
|
27
27
|
const auxiliaryTypeStore = (0, zod_to_ts_1.createAuxiliaryTypeStore)();
|
|
28
|
-
const requireParamsCode = (0, zod_to_ts_1.zodToTs)(route.requireParams, {
|
|
28
|
+
const requireParamsCode = (0, zod_to_ts_1.zodToTs)(route.requireParams.data, {
|
|
29
29
|
auxiliaryTypeStore,
|
|
30
30
|
});
|
|
31
31
|
const responseStructureCode = (0, zod_to_ts_1.zodToTs)(route.responseStructure, {
|
|
@@ -44,7 +44,7 @@ function generateStaticRouteFileV3(appName, data) {
|
|
|
44
44
|
const keyName = Object.keys(data);
|
|
45
45
|
return keyName
|
|
46
46
|
.map((keyName) => {
|
|
47
|
-
const requireLine = `requireParams :
|
|
47
|
+
const requireLine = `requireParams : { data :${data[keyName].requireParams} }`;
|
|
48
48
|
const responseLine = `responseStructure : {
|
|
49
49
|
data : ${data[keyName].responseStructure},
|
|
50
50
|
message: string
|
|
@@ -12,7 +12,7 @@ class GGApi_v3 {
|
|
|
12
12
|
get(url, requireParams) {
|
|
13
13
|
return new Promise((resolve, reject) => {
|
|
14
14
|
axios_1.default
|
|
15
|
-
.get(this.urlPrefix + url, { params: requireParams })
|
|
15
|
+
.get((this.urlPrefix + url), { params: requireParams })
|
|
16
16
|
.then((response) => {
|
|
17
17
|
resolve(response.data);
|
|
18
18
|
})
|
|
@@ -25,7 +25,7 @@ class GGApi_v3 {
|
|
|
25
25
|
post(url, requireParams) {
|
|
26
26
|
return new Promise((resolve, reject) => {
|
|
27
27
|
axios_1.default
|
|
28
|
-
.post(this.urlPrefix + url, { data: requireParams })
|
|
28
|
+
.post((this.urlPrefix + url), { data: requireParams })
|
|
29
29
|
.then((response) => {
|
|
30
30
|
resolve(response.data);
|
|
31
31
|
})
|
|
@@ -38,7 +38,7 @@ class GGApi_v3 {
|
|
|
38
38
|
put(url, requireParams) {
|
|
39
39
|
return new Promise((resolve, reject) => {
|
|
40
40
|
axios_1.default
|
|
41
|
-
.put(this.urlPrefix + url, { data: requireParams })
|
|
41
|
+
.put((this.urlPrefix + url), { data: requireParams })
|
|
42
42
|
.then((response) => {
|
|
43
43
|
resolve(response.data);
|
|
44
44
|
})
|
|
@@ -51,7 +51,9 @@ class GGApi_v3 {
|
|
|
51
51
|
delete(url, requireParams) {
|
|
52
52
|
return new Promise((resolve, reject) => {
|
|
53
53
|
axios_1.default
|
|
54
|
-
.delete(this.urlPrefix + url, {
|
|
54
|
+
.delete((this.urlPrefix + url), {
|
|
55
|
+
data: { data: requireParams },
|
|
56
|
+
})
|
|
55
57
|
.then((response) => {
|
|
56
58
|
resolve(response.data);
|
|
57
59
|
})
|
|
@@ -2,8 +2,10 @@ export interface staticRouteInterface_hotel_v3 {
|
|
|
2
2
|
get: {
|
|
3
3
|
"/api/v2/hotel/users/id": {
|
|
4
4
|
requireParams: {
|
|
5
|
-
|
|
6
|
-
|
|
5
|
+
data: {
|
|
6
|
+
name: string;
|
|
7
|
+
age: number;
|
|
8
|
+
};
|
|
7
9
|
};
|
|
8
10
|
responseStructure: {
|
|
9
11
|
data: {
|
|
@@ -13,21 +15,24 @@ export interface staticRouteInterface_hotel_v3 {
|
|
|
13
15
|
message: string;
|
|
14
16
|
};
|
|
15
17
|
};
|
|
18
|
+
};
|
|
19
|
+
post: {
|
|
16
20
|
"/api/v2/hotel/item": {
|
|
17
21
|
requireParams: {
|
|
18
|
-
|
|
19
|
-
|
|
22
|
+
data: {
|
|
23
|
+
name: string;
|
|
24
|
+
price?: number | undefined;
|
|
25
|
+
};
|
|
20
26
|
};
|
|
21
27
|
responseStructure: {
|
|
22
28
|
data: {
|
|
23
|
-
value:
|
|
29
|
+
value: number;
|
|
24
30
|
address: string;
|
|
25
31
|
};
|
|
26
32
|
message: string;
|
|
27
33
|
};
|
|
28
34
|
};
|
|
29
35
|
};
|
|
30
|
-
post: {};
|
|
31
36
|
put: {};
|
|
32
37
|
delete: {};
|
|
33
38
|
}
|
package/dist/v3/run_v3.test.js
CHANGED
|
@@ -16,6 +16,7 @@ exports.addMyTestMW = exports.hotel_model_const_temp = void 0;
|
|
|
16
16
|
const express_1 = __importDefault(require("express"));
|
|
17
17
|
const GGExpressV3_1 = __importDefault(require("./GGExpressV3"));
|
|
18
18
|
const zod_1 = __importDefault(require("zod"));
|
|
19
|
+
const apiConnector_hotel_v3_1 = require("./output/apiConnector_hotel_v3");
|
|
19
20
|
exports.hotel_model_const_temp = {
|
|
20
21
|
booking: {
|
|
21
22
|
id: "number",
|
|
@@ -48,10 +49,12 @@ function run() {
|
|
|
48
49
|
const app = (0, express_1.default)();
|
|
49
50
|
const ggapp = new GGExpressV3_1.default(app, "hotel", ["./output"]);
|
|
50
51
|
ggapp.get("/api/v2/hotel/users/id", {
|
|
51
|
-
requireParams:
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
52
|
+
requireParams: {
|
|
53
|
+
data: zod_1.default.object({
|
|
54
|
+
name: zod_1.default.string(),
|
|
55
|
+
age: zod_1.default.number(),
|
|
56
|
+
}),
|
|
57
|
+
},
|
|
55
58
|
responseStructure: zod_1.default.object({
|
|
56
59
|
value: zod_1.default.string(),
|
|
57
60
|
address: zod_1.default.string(),
|
|
@@ -60,10 +63,12 @@ function run() {
|
|
|
60
63
|
req.query.data.age;
|
|
61
64
|
}, () => { });
|
|
62
65
|
ggapp.post("/api/v2/hotel/item", {
|
|
63
|
-
requireParams:
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
66
|
+
requireParams: {
|
|
67
|
+
data: zod_1.default.object({
|
|
68
|
+
name: zod_1.default.string(),
|
|
69
|
+
price: zod_1.default.number().optional(),
|
|
70
|
+
}),
|
|
71
|
+
},
|
|
67
72
|
responseStructure: zod_1.default.object({
|
|
68
73
|
value: zod_1.default.number(),
|
|
69
74
|
address: zod_1.default.string(),
|
|
@@ -77,11 +82,13 @@ function run() {
|
|
|
77
82
|
value: 1,
|
|
78
83
|
});
|
|
79
84
|
});
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
+
const api = new apiConnector_hotel_v3_1.GGApi_v3({ urlPrefix: "xxx" });
|
|
86
|
+
api.get("/api/v2/hotel/users/id", {
|
|
87
|
+
data: {
|
|
88
|
+
name: "",
|
|
89
|
+
age: 0,
|
|
90
|
+
},
|
|
91
|
+
});
|
|
85
92
|
app.listen(3002, () => __awaiter(this, void 0, void 0, function* () {
|
|
86
93
|
yield ggapp.generateAPIFiles();
|
|
87
94
|
console.log("done");
|
package/package.json
CHANGED
package/src/v3/GGExpressV3.ts
CHANGED
|
@@ -29,6 +29,10 @@ type MyBodyRequest<RQ extends z.ZodTypeAny> = Request<
|
|
|
29
29
|
{}
|
|
30
30
|
>
|
|
31
31
|
|
|
32
|
+
export type RequestStructure<RQ extends z.ZodTypeAny> = {
|
|
33
|
+
data: RQ
|
|
34
|
+
}
|
|
35
|
+
|
|
32
36
|
type MyRequestStructure<RQ extends z.ZodTypeAny> = {
|
|
33
37
|
data: z.infer<RQ>
|
|
34
38
|
}
|
|
@@ -65,7 +69,7 @@ export default class GGExpressV3<
|
|
|
65
69
|
method: M,
|
|
66
70
|
url: string | string[],
|
|
67
71
|
options: {
|
|
68
|
-
requireParams: RQ
|
|
72
|
+
requireParams: RequestStructure<RQ>
|
|
69
73
|
responseStructure: RS
|
|
70
74
|
},
|
|
71
75
|
...middlewares: Array<
|
|
@@ -110,7 +114,7 @@ export default class GGExpressV3<
|
|
|
110
114
|
| `${urlPrefix}/${appName}/${string}`
|
|
111
115
|
| `${urlPrefix}/${appName}/${string}`[],
|
|
112
116
|
options: {
|
|
113
|
-
requireParams: RQ
|
|
117
|
+
requireParams: RequestStructure<RQ>
|
|
114
118
|
responseStructure: RS
|
|
115
119
|
},
|
|
116
120
|
...middlewares: Array<
|
|
@@ -133,7 +137,7 @@ export default class GGExpressV3<
|
|
|
133
137
|
| `${urlPrefix}/${appName}/${string}`
|
|
134
138
|
| `${urlPrefix}/${appName}/${string}`[],
|
|
135
139
|
options: {
|
|
136
|
-
requireParams: RQ
|
|
140
|
+
requireParams: RequestStructure<RQ>
|
|
137
141
|
responseStructure: RS
|
|
138
142
|
},
|
|
139
143
|
...middlewares: Array<
|
|
@@ -156,7 +160,7 @@ export default class GGExpressV3<
|
|
|
156
160
|
| `${urlPrefix}/${appName}/${string}`
|
|
157
161
|
| `${urlPrefix}/${appName}/${string}`[],
|
|
158
162
|
options: {
|
|
159
|
-
requireParams: RQ
|
|
163
|
+
requireParams: RequestStructure<RQ>
|
|
160
164
|
responseStructure: RS
|
|
161
165
|
},
|
|
162
166
|
...middlewares: Array<
|
|
@@ -179,7 +183,7 @@ export default class GGExpressV3<
|
|
|
179
183
|
| `${urlPrefix}/${appName}/${string}`
|
|
180
184
|
| `${urlPrefix}/${appName}/${string}`[],
|
|
181
185
|
options: {
|
|
182
|
-
requireParams: RQ
|
|
186
|
+
requireParams: RequestStructure<RQ>
|
|
183
187
|
responseStructure: RS
|
|
184
188
|
},
|
|
185
189
|
...middlewares: Array<
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import z from "zod"
|
|
2
|
-
import { Method } from "./GGExpressV3"
|
|
2
|
+
import { Method, RequestStructure } from "./GGExpressV3"
|
|
3
3
|
import { ConstSchemaType, CustomType } from "../v2/typeResolver"
|
|
4
4
|
import { createAuxiliaryTypeStore, zodToTs } from "zod-to-ts"
|
|
5
5
|
import ts from "typescript"
|
|
@@ -20,7 +20,7 @@ export function typeNodeToString(node: ts.TypeNode): string {
|
|
|
20
20
|
export type routeListV3 = {
|
|
21
21
|
method: Method
|
|
22
22
|
url: string
|
|
23
|
-
requireParams: z.ZodTypeAny
|
|
23
|
+
requireParams: RequestStructure<z.ZodTypeAny>
|
|
24
24
|
responseStructure: z.ZodTypeAny
|
|
25
25
|
}
|
|
26
26
|
|
|
@@ -49,7 +49,7 @@ function extract(
|
|
|
49
49
|
): PrepareRouteStructure {
|
|
50
50
|
for (const route of allData) {
|
|
51
51
|
const auxiliaryTypeStore = createAuxiliaryTypeStore()
|
|
52
|
-
const requireParamsCode = zodToTs(route.requireParams, {
|
|
52
|
+
const requireParamsCode = zodToTs(route.requireParams.data, {
|
|
53
53
|
auxiliaryTypeStore,
|
|
54
54
|
})
|
|
55
55
|
const responseStructureCode = zodToTs(route.responseStructure, {
|
|
@@ -73,7 +73,7 @@ export function generateStaticRouteFileV3(
|
|
|
73
73
|
|
|
74
74
|
return keyName
|
|
75
75
|
.map((keyName) => {
|
|
76
|
-
const requireLine = `requireParams :
|
|
76
|
+
const requireLine = `requireParams : { data :${data[keyName].requireParams} }`
|
|
77
77
|
const responseLine = `responseStructure : {
|
|
78
78
|
data : ${data[keyName].responseStructure},
|
|
79
79
|
message: string
|
|
@@ -1,20 +1,19 @@
|
|
|
1
|
-
|
|
2
1
|
import axios from "axios"
|
|
3
2
|
import { staticRouteInterface_hotel_v3 } from "./staticRouteInterface_hotel_v3"
|
|
4
3
|
|
|
5
4
|
export class GGApi_v3 {
|
|
6
|
-
urlPrefix
|
|
7
|
-
constructor(input:{ urlPrefix
|
|
5
|
+
urlPrefix: string
|
|
6
|
+
constructor(input: { urlPrefix: string }) {
|
|
8
7
|
this.urlPrefix = input.urlPrefix
|
|
9
8
|
}
|
|
10
9
|
|
|
11
10
|
get<T extends keyof staticRouteInterface_hotel_v3["get"]>(
|
|
12
11
|
url: T,
|
|
13
|
-
requireParams: staticRouteInterface_hotel_v3["get"][T]["requireParams"]
|
|
12
|
+
requireParams: staticRouteInterface_hotel_v3["get"][T]["requireParams"],
|
|
14
13
|
): Promise<staticRouteInterface_hotel_v3["get"][T]["responseStructure"]> {
|
|
15
14
|
return new Promise((resolve, reject) => {
|
|
16
15
|
axios
|
|
17
|
-
.get(this.urlPrefix + url as string, { params: requireParams })
|
|
16
|
+
.get((this.urlPrefix + url) as string, { params: requireParams })
|
|
18
17
|
.then((response) => {
|
|
19
18
|
resolve(response.data)
|
|
20
19
|
})
|
|
@@ -27,11 +26,11 @@ export class GGApi_v3 {
|
|
|
27
26
|
|
|
28
27
|
post<T extends keyof staticRouteInterface_hotel_v3["post"]>(
|
|
29
28
|
url: T,
|
|
30
|
-
requireParams: staticRouteInterface_hotel_v3["post"][T]["requireParams"]
|
|
29
|
+
requireParams: staticRouteInterface_hotel_v3["post"][T]["requireParams"],
|
|
31
30
|
): Promise<staticRouteInterface_hotel_v3["post"][T]["responseStructure"]> {
|
|
32
31
|
return new Promise((resolve, reject) => {
|
|
33
32
|
axios
|
|
34
|
-
.post(this.urlPrefix + url as string, { data: requireParams })
|
|
33
|
+
.post((this.urlPrefix + url) as string, { data: requireParams })
|
|
35
34
|
.then((response) => {
|
|
36
35
|
resolve(response.data)
|
|
37
36
|
})
|
|
@@ -43,11 +42,11 @@ export class GGApi_v3 {
|
|
|
43
42
|
}
|
|
44
43
|
put<T extends keyof staticRouteInterface_hotel_v3["put"]>(
|
|
45
44
|
url: T,
|
|
46
|
-
requireParams: staticRouteInterface_hotel_v3["put"][T]["requireParams"]
|
|
45
|
+
requireParams: staticRouteInterface_hotel_v3["put"][T]["requireParams"],
|
|
47
46
|
): Promise<staticRouteInterface_hotel_v3["put"][T]["responseStructure"]> {
|
|
48
47
|
return new Promise((resolve, reject) => {
|
|
49
48
|
axios
|
|
50
|
-
.put(this.urlPrefix + url as string, { data: requireParams })
|
|
49
|
+
.put((this.urlPrefix + url) as string, { data: requireParams })
|
|
51
50
|
.then((response) => {
|
|
52
51
|
resolve(response.data)
|
|
53
52
|
})
|
|
@@ -59,11 +58,13 @@ export class GGApi_v3 {
|
|
|
59
58
|
}
|
|
60
59
|
delete<T extends keyof staticRouteInterface_hotel_v3["delete"]>(
|
|
61
60
|
url: T,
|
|
62
|
-
requireParams: staticRouteInterface_hotel_v3["delete"][T]["requireParams"]
|
|
61
|
+
requireParams: staticRouteInterface_hotel_v3["delete"][T]["requireParams"],
|
|
63
62
|
): Promise<staticRouteInterface_hotel_v3["delete"][T]["responseStructure"]> {
|
|
64
63
|
return new Promise((resolve, reject) => {
|
|
65
64
|
axios
|
|
66
|
-
.delete(this.urlPrefix + url as string, {
|
|
65
|
+
.delete((this.urlPrefix + url) as string, {
|
|
66
|
+
data: { data: requireParams },
|
|
67
|
+
})
|
|
67
68
|
.then((response) => {
|
|
68
69
|
resolve(response.data)
|
|
69
70
|
})
|
|
@@ -1,34 +1,38 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
requireParams : {
|
|
19
|
-
name: string;
|
|
20
|
-
price?: number | undefined;
|
|
21
|
-
},responseStructure : {
|
|
22
|
-
data : {
|
|
23
|
-
value: string;
|
|
24
|
-
address: string;
|
|
25
|
-
},
|
|
26
|
-
message: string
|
|
27
|
-
},
|
|
28
|
-
|
|
29
|
-
} },
|
|
30
|
-
post : { },
|
|
31
|
-
put : { },
|
|
32
|
-
delete : { },
|
|
1
|
+
export interface staticRouteInterface_hotel_v3 {
|
|
2
|
+
get: {
|
|
3
|
+
"/api/v2/hotel/users/id": {
|
|
4
|
+
requireParams: {
|
|
5
|
+
data: {
|
|
6
|
+
name: string
|
|
7
|
+
age: number
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
responseStructure: {
|
|
11
|
+
data: {
|
|
12
|
+
value: string
|
|
13
|
+
address: string
|
|
14
|
+
}
|
|
15
|
+
message: string
|
|
16
|
+
}
|
|
17
|
+
}
|
|
33
18
|
}
|
|
34
|
-
|
|
19
|
+
post: {
|
|
20
|
+
"/api/v2/hotel/item": {
|
|
21
|
+
requireParams: {
|
|
22
|
+
data: {
|
|
23
|
+
name: string
|
|
24
|
+
price?: number | undefined
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
responseStructure: {
|
|
28
|
+
data: {
|
|
29
|
+
value: number
|
|
30
|
+
address: string
|
|
31
|
+
}
|
|
32
|
+
message: string
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
put: {}
|
|
37
|
+
delete: {}
|
|
38
|
+
}
|
package/src/v3/run_v3.test.ts
CHANGED
|
@@ -37,10 +37,12 @@ function run() {
|
|
|
37
37
|
ggapp.get(
|
|
38
38
|
"/api/v2/hotel/users/id",
|
|
39
39
|
{
|
|
40
|
-
requireParams:
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
40
|
+
requireParams: {
|
|
41
|
+
data: z.object({
|
|
42
|
+
name: z.string(),
|
|
43
|
+
age: z.number(),
|
|
44
|
+
}),
|
|
45
|
+
},
|
|
44
46
|
responseStructure: z.object({
|
|
45
47
|
value: z.string(),
|
|
46
48
|
address: z.string(),
|
|
@@ -54,10 +56,12 @@ function run() {
|
|
|
54
56
|
ggapp.post(
|
|
55
57
|
"/api/v2/hotel/item",
|
|
56
58
|
{
|
|
57
|
-
requireParams:
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
59
|
+
requireParams: {
|
|
60
|
+
data: z.object({
|
|
61
|
+
name: z.string(),
|
|
62
|
+
price: z.number().optional(),
|
|
63
|
+
}),
|
|
64
|
+
},
|
|
61
65
|
responseStructure: z.object({
|
|
62
66
|
value: z.number(),
|
|
63
67
|
address: z.string(),
|
|
@@ -73,11 +77,13 @@ function run() {
|
|
|
73
77
|
})
|
|
74
78
|
},
|
|
75
79
|
)
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
80
|
+
const api = new GGApi_v3({ urlPrefix: "xxx" })
|
|
81
|
+
api.get("/api/v2/hotel/users/id", {
|
|
82
|
+
data: {
|
|
83
|
+
name: "",
|
|
84
|
+
age: 0,
|
|
85
|
+
},
|
|
86
|
+
})
|
|
81
87
|
|
|
82
88
|
app.listen(3002, async () => {
|
|
83
89
|
await ggapp.generateAPIFiles()
|