gg-express 1.0.61 → 1.0.62

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.
@@ -1,8 +1,7 @@
1
1
  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
- type AsConstArray<T extends readonly any[]> = [...T];
5
- type paramType = "number" | "string" | "any" | AsConstArray<Array<string>> | AsConstArray<Array<number>>;
4
+ type paramType = "number" | "string" | "any" | string[] | number[];
6
5
  interface responseStructure {
7
6
  parameter: {
8
7
  [key: string]: "number" | "string";
package/dist/GGExpress.js CHANGED
@@ -12,9 +12,9 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
12
12
  return (mod && mod.__esModule) ? mod : { "default": mod };
13
13
  };
14
14
  Object.defineProperty(exports, "__esModule", { value: true });
15
+ const chalk_1 = __importDefault(require("chalk"));
15
16
  const fs_1 = __importDefault(require("fs"));
16
17
  const path_1 = __importDefault(require("path"));
17
- const chalk_1 = __importDefault(require("chalk"));
18
18
  const myExpressRouteList = [];
19
19
  class GGExpress {
20
20
  constructor(app, appName, outputPath) {
package/dist/run.test.js CHANGED
@@ -23,6 +23,7 @@ function run() {
23
23
  },
24
24
  },
25
25
  }, (req, res, next) => {
26
+ req.query.data.data.forEach((row) => row.name === "A");
26
27
  req.query.data.data;
27
28
  console.log(req.query);
28
29
  return res.json({
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gg-express",
3
- "version": "1.0.61",
3
+ "version": "1.0.62",
4
4
  "description": "",
5
5
  "main": "dist/GGExpress.js",
6
6
  "scripts": {
package/src/GGExpress.ts CHANGED
@@ -1,9 +1,8 @@
1
- import appRootPath from "app-root-path"
1
+ import chalk from "chalk"
2
2
  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 chalk from "chalk"
7
6
 
8
7
  type Unarray<T> = T extends (infer U)[] ? U : T
9
8
  type AsConstArray<T extends readonly any[]> = [...T]
@@ -11,8 +10,10 @@ type paramType =
11
10
  | "number"
12
11
  | "string"
13
12
  | "any"
14
- | AsConstArray<Array<string>>
15
- | AsConstArray<Array<number>>
13
+ // | AsConstArray<Array<string>>
14
+ // | AsConstArray<Array<number>>
15
+ | string[]
16
+ | number[]
16
17
  interface responseStructure {
17
18
  parameter: { [key: string]: "number" | "string" }
18
19
  dataType: "singleObject" | "arrayObject"
@@ -22,7 +23,7 @@ interface responseStructure {
22
23
  }
23
24
 
24
25
  interface requireParamsStructure {
25
- parameter: { [key: string]: "number" | "string" | "number[]" | "string[]" }
26
+ parameter: { [key: string]: "number" | "string" | "number[]" | "string[]" }
26
27
  dataType: "singleObject" | "arrayObject"
27
28
  structure: {
28
29
  [key: string]: paramType
@@ -34,9 +35,9 @@ type numberOrString<T> = T extends "number"
34
35
  ? number
35
36
  : T extends "string"
36
37
  ? string
37
- : T extends "number[]"
38
+ : T extends "number[]"
38
39
  ? number[]
39
- : T extends "string[]"
40
+ : T extends "string[]"
40
41
  ? string[]
41
42
  : T extends "any"
42
43
  ? any
@@ -56,9 +57,9 @@ type singleOrArrayObject<
56
57
  > = DT extends "arrayObject"
57
58
  ? {
58
59
  data: {
59
- parameter: L extends true ?
60
- Partial<{ [Key in keyof P]: numberOrString<P[Key]> }>:
61
- { [Key in keyof P]: numberOrString<P[Key]> }
60
+ parameter: L extends true
61
+ ? Partial<{ [Key in keyof P]: numberOrString<P[Key]> }>
62
+ : { [Key in keyof P]: numberOrString<P[Key]> }
62
63
  data: (J extends true
63
64
  ? Partial<{ [Key in K]: numberOrString<T[Key]> }>
64
65
  : { [Key in K]: numberOrString<T[Key]> })[]
@@ -80,12 +81,11 @@ type MyRequest<
80
81
  P extends requireParamsStructure["parameter"],
81
82
  J extends requireParamsStructure["isPartialStructure"],
82
83
  L extends requireParamsStructure["isPartialParameter"]
83
-
84
84
  > = Request<
85
85
  {},
86
86
  {},
87
- singleOrArrayObject<DT, T, K, P, J,L>,
88
- singleOrArrayObject<DT, T, K, P, J,L>,
87
+ singleOrArrayObject<DT, T, K, P, J, L>,
88
+ singleOrArrayObject<DT, T, K, P, J, L>,
89
89
  {}
90
90
  >
91
91
 
@@ -141,7 +141,7 @@ export default class GGExpress<appName extends string> {
141
141
  },
142
142
  ...middlewares: Array<
143
143
  (
144
- req: MyRequest<M["dataType"], T, K, P, J,L>,
144
+ req: MyRequest<M["dataType"], T, K, P, J, L>,
145
145
  res: MyResponse<R["dataType"], RS, KR, PP, J>,
146
146
  next: NextFunction
147
147
  ) => any
@@ -157,7 +157,7 @@ export default class GGExpress<appName extends string> {
157
157
  return this.express[method](
158
158
  url,
159
159
  (
160
- req: MyRequest<M["dataType"], T, K, P, J,L>,
160
+ req: MyRequest<M["dataType"], T, K, P, J, L>,
161
161
  res: Response,
162
162
  next: NextFunction
163
163
  ) => {
@@ -177,7 +177,6 @@ export default class GGExpress<appName extends string> {
177
177
  PP extends R["parameter"],
178
178
  J extends M["isPartialStructure"],
179
179
  L extends M["isPartialParameter"]
180
-
181
180
  >(
182
181
  url: `/api/${appName}/${string}`,
183
182
  options: {
@@ -186,7 +185,7 @@ export default class GGExpress<appName extends string> {
186
185
  },
187
186
  ...middlewares: Array<
188
187
  (
189
- req: MyRequest<M["dataType"], T, K, P, J,L>,
188
+ req: MyRequest<M["dataType"], T, K, P, J, L>,
190
189
  res: MyResponse<R["dataType"], RS, KR, PP, J>,
191
190
  next: NextFunction
192
191
  ) => any
@@ -206,7 +205,6 @@ export default class GGExpress<appName extends string> {
206
205
  PP extends R["parameter"],
207
206
  J extends M["isPartialStructure"],
208
207
  L extends M["isPartialParameter"]
209
-
210
208
  >(
211
209
  url: `/api/${appName}/${string}`,
212
210
  options: {
@@ -215,7 +213,7 @@ export default class GGExpress<appName extends string> {
215
213
  },
216
214
  ...middlewares: Array<
217
215
  (
218
- req: MyRequest<M["dataType"], T, K, P, J,L>,
216
+ req: MyRequest<M["dataType"], T, K, P, J, L>,
219
217
  res: MyResponse<R["dataType"], RS, KR, PP, J>,
220
218
  next: NextFunction
221
219
  ) => any
@@ -234,7 +232,6 @@ export default class GGExpress<appName extends string> {
234
232
  PP extends R["parameter"],
235
233
  J extends M["isPartialStructure"],
236
234
  L extends M["isPartialParameter"]
237
-
238
235
  >(
239
236
  url: `/api/${appName}/${string}`,
240
237
  options: {
@@ -243,7 +240,7 @@ export default class GGExpress<appName extends string> {
243
240
  },
244
241
  ...middlewares: Array<
245
242
  (
246
- req: MyRequest<M["dataType"], T, K, P, J,L>,
243
+ req: MyRequest<M["dataType"], T, K, P, J, L>,
247
244
  res: MyResponse<R["dataType"], RS, KR, PP, J>,
248
245
  next: NextFunction
249
246
  ) => any
@@ -262,7 +259,6 @@ export default class GGExpress<appName extends string> {
262
259
  PP extends R["parameter"],
263
260
  J extends M["isPartialStructure"],
264
261
  L extends M["isPartialParameter"]
265
-
266
262
  >(
267
263
  url: `/api/${appName}/${string}`,
268
264
  options: {
@@ -271,7 +267,7 @@ export default class GGExpress<appName extends string> {
271
267
  },
272
268
  ...middlewares: Array<
273
269
  (
274
- req: MyRequest<M["dataType"], T, K, P, J,L>,
270
+ req: MyRequest<M["dataType"], T, K, P, J, L>,
275
271
  res: MyResponse<R["dataType"], RS, KR, PP, J>,
276
272
  next: NextFunction
277
273
  ) => any
@@ -371,8 +367,7 @@ export default class GGExpress<appName extends string> {
371
367
  }
372
368
  const requireParameterCode = () => {
373
369
  if (parameterCode === "") return ""
374
- else
375
- return ` parameter:${isPartial(`{${parameterCode}}`)}`
370
+ else return ` parameter:${isPartial(`{${parameterCode}}`)}`
376
371
  // return ` parameter:{${parameterCode}} `
377
372
  }
378
373
  const requireDataCode = () => {
package/src/run.test.ts CHANGED
@@ -7,7 +7,7 @@ function run() {
7
7
  "/api/hotel/users/id",
8
8
  {
9
9
  requireParams: {
10
- parameter: {files : "string[]"},
10
+ parameter: { files: "string[]" },
11
11
  dataType: "arrayObject",
12
12
  structure: { id: "number", name: ["A", "B"] as const },
13
13
  },
@@ -21,6 +21,7 @@ function run() {
21
21
  },
22
22
  },
23
23
  (req, res, next) => {
24
+ req.query.data.data.forEach((row) => row.name === "A")
24
25
  req.query.data.data
25
26
  console.log(req.query)
26
27
  return res.json({