gg-express 1.0.54 → 1.0.55

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.
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,90 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ const GGExpress_1 = __importDefault(require("./GGExpress"));
7
+ const express_1 = __importDefault(require("express"));
8
+ function run() {
9
+ const app = (0, express_1.default)();
10
+ const ggapp = new GGExpress_1.default(app, ["./"]);
11
+ ggapp.get("/api/gg/users/id", {
12
+ requireParams: {
13
+ parameter: {},
14
+ dataType: "arrayObject",
15
+ structure: { id: "number" },
16
+ },
17
+ responseStructure: {
18
+ parameter: { numberOfPeople: "number", itemName: "string" },
19
+ dataType: "arrayObject",
20
+ structure: {
21
+ id: "number",
22
+ name: "string",
23
+ },
24
+ },
25
+ }, (req, res, next) => {
26
+ req.query.data.data;
27
+ console.log(req.query);
28
+ return res.json({
29
+ message: "",
30
+ status: "SUCCESS",
31
+ data: [],
32
+ parameter: {
33
+ itemName: "",
34
+ numberOfPeople: 2,
35
+ },
36
+ });
37
+ });
38
+ ggapp.post("/api/gg/item", {
39
+ requireParams: {
40
+ parameter: {
41
+ lotNumber: "number",
42
+ },
43
+ isPartialStructure: true,
44
+ dataType: "singleObject",
45
+ structure: {
46
+ id: "number",
47
+ name: ["item-1", "item-2"],
48
+ price: "number",
49
+ },
50
+ },
51
+ responseStructure: {
52
+ parameter: { numberOfPeople: "number", itemName: "string" },
53
+ dataType: "arrayObject",
54
+ structure: {
55
+ id: "number",
56
+ name: "string",
57
+ },
58
+ },
59
+ }, (req, res, next) => {
60
+ req.body.data.data;
61
+ // in body or query, you can access only requireParams that you declare at start
62
+ const data = req.body.data;
63
+ /* data structure
64
+ data: {
65
+ parameter: {
66
+ lotNumber: number;
67
+ };
68
+ data: {
69
+ id: number;
70
+ name: string;
71
+ price: number;
72
+ }[];
73
+ }
74
+ */
75
+ // also res.json(), you can only return structure like responseStructure that you declare at start
76
+ return res.json({
77
+ message: "",
78
+ status: "SUCCESS",
79
+ data: [],
80
+ parameter: {
81
+ itemName: "",
82
+ numberOfPeople: 2,
83
+ },
84
+ });
85
+ });
86
+ app.listen(3002, () => {
87
+ ggapp.generateAPIFiles();
88
+ });
89
+ }
90
+ run();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gg-express",
3
- "version": "1.0.54",
3
+ "version": "1.0.55",
4
4
  "description": "",
5
5
  "main": "dist/GGExpress.js",
6
6
  "scripts": {
File without changes