gg-express 1.0.32 → 1.0.36
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/GGApi.js +7 -1
- package/dist/GGExpress.d.ts +15 -11
- package/dist/apiConnector.js +1 -1
- package/dist/test.js +1 -0
- package/package.json +1 -1
- package/src/GGApi.ts +9 -6
- package/src/GGExpress.ts +11 -4
- package/src/apiConnector.ts +2 -2
- package/src/test.ts +1 -0
package/dist/GGApi.js
CHANGED
|
@@ -73,7 +73,13 @@ function run() {
|
|
|
73
73
|
// parameter: { lotNumber: 1223 },
|
|
74
74
|
// data: [],
|
|
75
75
|
// })
|
|
76
|
-
const data2 =
|
|
76
|
+
// const data2 = await api.get(
|
|
77
|
+
// ("http://localhost:3002" + "/api/users/id") as any,
|
|
78
|
+
// {
|
|
79
|
+
// data: [{ id: 2 }, { id: 3 }, { id: 20 }],
|
|
80
|
+
// }
|
|
81
|
+
// )
|
|
82
|
+
const data2 = yield api.get("/api/users/id", {
|
|
77
83
|
data: [{ id: 2 }, { id: 3 }, { id: 20 }],
|
|
78
84
|
});
|
|
79
85
|
});
|
package/dist/GGExpress.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ import { NextFunction, Request, Response } from "express";
|
|
|
2
2
|
import Express from "express-serve-static-core";
|
|
3
3
|
type Unarray<T> = T extends (infer U)[] ? U : T;
|
|
4
4
|
type AsConstArray<T extends readonly any[]> = [...T];
|
|
5
|
-
type paramType = "number" | "string" | AsConstArray<Array<string>> | AsConstArray<Array<number>>;
|
|
5
|
+
type paramType = "number" | "string" | "any" | AsConstArray<Array<string>> | AsConstArray<Array<number>>;
|
|
6
6
|
interface responseStructure {
|
|
7
7
|
parameter: {
|
|
8
8
|
[key: string]: "number" | "string";
|
|
@@ -21,20 +21,24 @@ interface requireParamsStructure {
|
|
|
21
21
|
[key: string]: paramType;
|
|
22
22
|
};
|
|
23
23
|
}
|
|
24
|
-
type numberOrString<T> = T extends "number" ? number : T extends "string" ? string : T extends string[] ? Unarray<T> : T extends number[] ? Unarray<T> : "error-type";
|
|
24
|
+
type numberOrString<T> = T extends "number" ? number : T extends "string" ? string : T extends "any" ? any : T extends string[] ? Unarray<T> : T extends number[] ? Unarray<T> : "error-type";
|
|
25
25
|
type singleOrArrayObject<DT extends requireParamsStructure["dataType"], T extends requireParamsStructure["structure"], K extends keyof T, P extends requireParamsStructure["parameter"]> = DT extends "arrayObject" ? {
|
|
26
|
-
parameter: {
|
|
27
|
-
[Key in keyof P]: numberOrString<P[Key]>;
|
|
28
|
-
};
|
|
29
26
|
data: {
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
|
|
27
|
+
parameter: {
|
|
28
|
+
[Key in keyof P]: numberOrString<P[Key]>;
|
|
29
|
+
};
|
|
30
|
+
data: {
|
|
31
|
+
[Key in K]: numberOrString<T[Key]>;
|
|
32
|
+
}[];
|
|
35
33
|
};
|
|
34
|
+
} : {
|
|
36
35
|
data: {
|
|
37
|
-
|
|
36
|
+
parameter: {
|
|
37
|
+
[Key in keyof P]: numberOrString<P[Key]>;
|
|
38
|
+
};
|
|
39
|
+
data: {
|
|
40
|
+
[Key in K]: numberOrString<T[Key]>;
|
|
41
|
+
};
|
|
38
42
|
};
|
|
39
43
|
};
|
|
40
44
|
type MyRequest<DT extends requireParamsStructure["dataType"], T extends requireParamsStructure["structure"], K extends keyof T, P extends requireParamsStructure["parameter"]> = Request<{}, {}, singleOrArrayObject<DT, T, K, P>, singleOrArrayObject<DT, T, K, P>, {}>;
|
package/dist/apiConnector.js
CHANGED
package/dist/test.js
CHANGED
package/package.json
CHANGED
package/src/GGApi.ts
CHANGED
|
@@ -74,11 +74,14 @@ async function run() {
|
|
|
74
74
|
// data: [],
|
|
75
75
|
// })
|
|
76
76
|
|
|
77
|
-
const data2 = await api.get(
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
)
|
|
77
|
+
// const data2 = await api.get(
|
|
78
|
+
// ("http://localhost:3002" + "/api/users/id") as any,
|
|
79
|
+
// {
|
|
80
|
+
// data: [{ id: 2 }, { id: 3 }, { id: 20 }],
|
|
81
|
+
// }
|
|
82
|
+
// )
|
|
83
|
+
const data2 = await api.get("/api/users/id", {
|
|
84
|
+
data: [{ id: 2 }, { id: 3 }, { id: 20 }],
|
|
85
|
+
})
|
|
83
86
|
}
|
|
84
87
|
run()
|
package/src/GGExpress.ts
CHANGED
|
@@ -11,6 +11,7 @@ type AsConstArray<T extends readonly any[]> = [...T]
|
|
|
11
11
|
type paramType =
|
|
12
12
|
| "number"
|
|
13
13
|
| "string"
|
|
14
|
+
| "any"
|
|
14
15
|
| AsConstArray<Array<string>>
|
|
15
16
|
| AsConstArray<Array<number>>
|
|
16
17
|
interface responseStructure {
|
|
@@ -32,6 +33,8 @@ type numberOrString<T> = T extends "number"
|
|
|
32
33
|
? number
|
|
33
34
|
: T extends "string"
|
|
34
35
|
? string
|
|
36
|
+
: T extends "any"
|
|
37
|
+
? any
|
|
35
38
|
: T extends string[]
|
|
36
39
|
? Unarray<T>
|
|
37
40
|
: T extends number[]
|
|
@@ -45,12 +48,16 @@ type singleOrArrayObject<
|
|
|
45
48
|
P extends requireParamsStructure["parameter"]
|
|
46
49
|
> = DT extends "arrayObject"
|
|
47
50
|
? {
|
|
48
|
-
|
|
49
|
-
|
|
51
|
+
data: {
|
|
52
|
+
parameter: { [Key in keyof P]: numberOrString<P[Key]> }
|
|
53
|
+
data: { [Key in K]: numberOrString<T[Key]> }[]
|
|
54
|
+
}
|
|
50
55
|
}
|
|
51
56
|
: {
|
|
52
|
-
|
|
53
|
-
|
|
57
|
+
data: {
|
|
58
|
+
parameter: { [Key in keyof P]: numberOrString<P[Key]> }
|
|
59
|
+
data: { [Key in K]: numberOrString<T[Key]> }
|
|
60
|
+
}
|
|
54
61
|
}
|
|
55
62
|
|
|
56
63
|
type MyRequest<
|
package/src/apiConnector.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
|
|
2
|
-
|
|
2
|
+
import axios from "axios"
|
|
3
3
|
import { staticRouteInterface } from "./staticRouteInterface"
|
|
4
4
|
|
|
5
5
|
export class GGApi {
|
|
@@ -11,7 +11,7 @@ export class GGApi {
|
|
|
11
11
|
): Promise<staticRouteInterface["get"][T]["responseStructure"]> {
|
|
12
12
|
return new Promise((resolve, reject) => {
|
|
13
13
|
axios
|
|
14
|
-
.get(url as string, { params: requireParams })
|
|
14
|
+
.get(url as string, { params: { data: requireParams } })
|
|
15
15
|
.then((response) => {
|
|
16
16
|
resolve(response.data)
|
|
17
17
|
})
|