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 CHANGED
@@ -73,7 +73,13 @@ function run() {
73
73
  // parameter: { lotNumber: 1223 },
74
74
  // data: [],
75
75
  // })
76
- const data2 = yield api.get(("http://localhost:3002" + "/api/users/id"), {
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
  });
@@ -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
- [Key in K]: numberOrString<T[Key]>;
31
- }[];
32
- } : {
33
- parameter: {
34
- [Key in keyof P]: numberOrString<P[Key]>;
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
- [Key in K]: numberOrString<T[Key]>;
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>, {}>;
@@ -10,7 +10,7 @@ class GGApi {
10
10
  get(url, requireParams) {
11
11
  return new Promise((resolve, reject) => {
12
12
  axios_1.default
13
- .get(url, { params: requireParams })
13
+ .get(url, { params: { data: requireParams } })
14
14
  .then((response) => {
15
15
  resolve(response.data);
16
16
  })
package/dist/test.js CHANGED
@@ -23,6 +23,7 @@ function run() {
23
23
  },
24
24
  },
25
25
  }, (req, res, next) => {
26
+ req.query.data.data;
26
27
  console.log(req.query);
27
28
  return res.json({
28
29
  message: "",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gg-express",
3
- "version": "1.0.32",
3
+ "version": "1.0.36",
4
4
  "description": "",
5
5
  "main": "dist/GGExpress.js",
6
6
  "scripts": {
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
- ("http://localhost:3002" + "/api/users/id") as any,
79
- {
80
- data: [{ id: 2 }, { id: 3 }, { id: 20 }],
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
- parameter: { [Key in keyof P]: numberOrString<P[Key]> }
49
- data: { [Key in K]: numberOrString<T[Key]> }[]
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
- parameter: { [Key in keyof P]: numberOrString<P[Key]> }
53
- data: { [Key in K]: numberOrString<T[Key]> }
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<
@@ -1,5 +1,5 @@
1
1
 
2
- import axios from "axios"
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
  })
package/src/test.ts CHANGED
@@ -21,6 +21,7 @@ function run() {
21
21
  },
22
22
  },
23
23
  (req, res, next) => {
24
+ req.query.data.data
24
25
  console.log(req.query)
25
26
  return res.json({
26
27
  message: "",