axe-api 1.0.0-rc9 → 1.0.0

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.
Files changed (136) hide show
  1. package/build/index.d.ts +1 -0
  2. package/build/index.js +1 -0
  3. package/build/src/Builders/IndexBuilder.d.ts +7 -0
  4. package/build/src/Builders/IndexBuilder.js +35 -0
  5. package/build/src/Builders/ModelTreeBuilder.js +2 -1
  6. package/build/src/Builders/RouterBuilder.js +22 -11
  7. package/build/src/Builders/SwaggerBuilder.d.ts +2 -0
  8. package/build/src/Builders/SwaggerBuilder.js +609 -0
  9. package/build/src/Enums.d.ts +6 -1
  10. package/build/src/Enums.js +7 -1
  11. package/build/src/Handlers/DocsHandler.js +41 -0
  12. package/build/src/Handlers/ErrorHandler.d.ts +6 -0
  13. package/build/src/Handlers/ErrorHandler.js +12 -0
  14. package/build/src/Handlers/Helpers.d.ts +16 -4
  15. package/build/src/Handlers/Helpers.js +202 -5
  16. package/build/src/Handlers/RequestHandler.d.ts +4 -1
  17. package/build/src/Handlers/RequestHandler.js +36 -40
  18. package/build/src/Handlers/{DocsHTMLHandler.js → SwaggerHandler.js} +8 -7
  19. package/build/src/Interfaces.d.ts +103 -35
  20. package/build/src/Middlewares/RateLimit/AdaptorFactory.d.ts +3 -3
  21. package/build/src/Middlewares/RateLimit/MemoryAdaptor.d.ts +2 -2
  22. package/build/src/Middlewares/RateLimit/RedisAdaptor.d.ts +12 -4
  23. package/build/src/Middlewares/RateLimit/RedisAdaptor.js +24 -0
  24. package/build/src/Middlewares/RateLimit/index.d.ts +22 -3
  25. package/build/src/Middlewares/RateLimit/index.js +23 -3
  26. package/build/src/Model.d.ts +256 -10
  27. package/build/src/Model.js +322 -30
  28. package/build/src/Phases/All/FetchPhase.d.ts +2 -2
  29. package/build/src/Phases/All/PreparePhase.d.ts +2 -2
  30. package/build/src/Phases/All/index.d.ts +1 -1
  31. package/build/src/Phases/CacheTagCleanPhase.d.ts +3 -0
  32. package/build/src/{Handlers/MetadataHandler.js → Phases/CacheTagCleanPhase.js} +6 -10
  33. package/build/src/Phases/Delete/ActionPhase.d.ts +2 -2
  34. package/build/src/Phases/Delete/ActionPhase.js +21 -2
  35. package/build/src/Phases/Delete/PreparePhase.d.ts +2 -2
  36. package/build/src/Phases/Delete/QueryPhase.d.ts +2 -2
  37. package/build/src/Phases/Delete/ResponsePhase.d.ts +2 -2
  38. package/build/src/Phases/Delete/ResponsePhase.js +2 -1
  39. package/build/src/Phases/Delete/index.d.ts +4 -4
  40. package/build/src/Phases/ForceDelete/ActionPhase.d.ts +2 -2
  41. package/build/src/Phases/ForceDelete/ActionPhase.js +7 -0
  42. package/build/src/Phases/ForceDelete/PreparePhase.d.ts +2 -2
  43. package/build/src/Phases/ForceDelete/QueryPhase.d.ts +2 -2
  44. package/build/src/Phases/ForceDelete/index.d.ts +3 -3
  45. package/build/src/Phases/GetCachePhase.d.ts +3 -0
  46. package/build/src/Phases/GetCachePhase.js +39 -0
  47. package/build/src/Phases/List/RelationalPhase.d.ts +2 -2
  48. package/build/src/Phases/List/ResultPhase.d.ts +2 -2
  49. package/build/src/Phases/List/ResultPhase.js +9 -1
  50. package/build/src/Phases/List/SerializePhase.d.ts +2 -2
  51. package/build/src/Phases/List/index.d.ts +3 -3
  52. package/build/src/Phases/Paginate/FetchPhase.d.ts +2 -2
  53. package/build/src/Phases/Paginate/PreparePhase.d.ts +2 -2
  54. package/build/src/Phases/Paginate/index.d.ts +2 -2
  55. package/build/src/Phases/Patch/PrepareActionPhase.d.ts +2 -2
  56. package/build/src/Phases/Patch/PrepareActionPhase.js +13 -10
  57. package/build/src/Phases/Patch/index.d.ts +1 -1
  58. package/build/src/Phases/Search/FetchPhase.d.ts +3 -0
  59. package/build/src/Phases/Search/FetchPhase.js +66 -0
  60. package/build/src/Phases/Search/PreparePhase.d.ts +3 -0
  61. package/build/src/Phases/Search/PreparePhase.js +19 -0
  62. package/build/src/Phases/Search/index.d.ts +5 -0
  63. package/build/src/Phases/Search/index.js +11 -0
  64. package/build/src/Phases/Show/FetchPhase.d.ts +2 -2
  65. package/build/src/Phases/Show/FetchPhase.js +11 -1
  66. package/build/src/Phases/Show/PreparePhase.d.ts +2 -2
  67. package/build/src/Phases/Show/PreparePhase.js +5 -13
  68. package/build/src/Phases/Show/index.d.ts +2 -2
  69. package/build/src/Phases/Single/GetPhase.d.ts +2 -2
  70. package/build/src/Phases/Single/PrepareGetPhase.d.ts +2 -2
  71. package/build/src/Phases/Single/RelationalPhase.d.ts +2 -2
  72. package/build/src/Phases/Single/ResultPhase.d.ts +2 -2
  73. package/build/src/Phases/Single/ResultPhase.js +9 -1
  74. package/build/src/Phases/Single/SerializePhase.d.ts +2 -2
  75. package/build/src/Phases/Single/index.d.ts +5 -5
  76. package/build/src/Phases/Store/ActionPhase.d.ts +2 -2
  77. package/build/src/Phases/Store/ActionPhase.js +18 -7
  78. package/build/src/Phases/Store/PreparePhase.d.ts +2 -2
  79. package/build/src/Phases/Store/PreparePhase.js +14 -9
  80. package/build/src/Phases/Store/ResultPhase.d.ts +3 -0
  81. package/build/src/Phases/Store/ResultPhase.js +23 -0
  82. package/build/src/Phases/Store/index.d.ts +3 -2
  83. package/build/src/Phases/Store/index.js +2 -0
  84. package/build/src/Phases/URLSearchParamPhase.d.ts +3 -0
  85. package/build/src/Phases/URLSearchParamPhase.js +37 -0
  86. package/build/src/Phases/Update/ActionPhase.d.ts +2 -2
  87. package/build/src/Phases/Update/ActionPhase.js +14 -3
  88. package/build/src/Phases/Update/PrepareActionPhase.d.ts +2 -2
  89. package/build/src/Phases/Update/PrepareActionPhase.js +13 -10
  90. package/build/src/Phases/Update/index.d.ts +2 -2
  91. package/build/src/Resolvers/ModelResolver.d.ts +1 -0
  92. package/build/src/Resolvers/ModelResolver.js +21 -2
  93. package/build/src/Resolvers/TransactionResolver.js +3 -15
  94. package/build/src/Resolvers/VersionConfigResolver.js +6 -1
  95. package/build/src/Resolvers/VersionResolver.js +1 -0
  96. package/build/src/Server.d.ts +5 -0
  97. package/build/src/Server.js +44 -11
  98. package/build/src/Services/APIService.d.ts +3 -3
  99. package/build/src/Services/APIService.js +3 -16
  100. package/build/src/Services/App.d.ts +94 -8
  101. package/build/src/Services/App.js +94 -29
  102. package/build/src/Services/AxeRequest.d.ts +51 -2
  103. package/build/src/Services/AxeRequest.js +51 -4
  104. package/build/src/Services/AxeResponse.d.ts +28 -1
  105. package/build/src/Services/AxeResponse.js +28 -0
  106. package/build/src/Services/ConverterService.d.ts +5 -3
  107. package/build/src/Services/DocumentationService.d.ts +5 -2
  108. package/build/src/Services/DocumentationService.js +13 -1
  109. package/build/src/Services/ElasticService.d.ts +14 -0
  110. package/build/src/Services/ElasticService.js +74 -0
  111. package/build/src/Services/IoCService.d.ts +29 -2
  112. package/build/src/Services/IoCService.js +33 -6
  113. package/build/src/Services/LimitService.d.ts +18 -0
  114. package/build/src/Services/LimitService.js +18 -0
  115. package/build/src/Services/ModelService.d.ts +9 -5
  116. package/build/src/Services/ModelService.js +11 -0
  117. package/build/src/Services/QueryService.d.ts +3 -3
  118. package/build/src/Services/QueryService.js +6 -0
  119. package/build/src/Services/SchemaValidatorService.d.ts +1 -0
  120. package/build/src/Services/SchemaValidatorService.js +4 -0
  121. package/build/src/Services/URLService.d.ts +6 -14
  122. package/build/src/Services/URLService.js +10 -8
  123. package/build/src/Steps/Event.d.ts +11 -0
  124. package/build/src/Steps/Event.js +17 -0
  125. package/build/src/Steps/Hook.d.ts +11 -0
  126. package/build/src/Steps/Hook.js +17 -0
  127. package/build/src/Steps/Phase.d.ts +11 -0
  128. package/build/src/Steps/Phase.js +18 -0
  129. package/build/src/Types.d.ts +12 -10
  130. package/build/src/constants.d.ts +8 -9
  131. package/build/src/constants.js +215 -152
  132. package/package.json +46 -36
  133. package/build/src/Middlewares/RateLimit/IAdaptor.d.ts +0 -6
  134. package/build/src/Middlewares/RateLimit/IAdaptor.js +0 -2
  135. /package/build/src/Handlers/{DocsHTMLHandler.d.ts → DocsHandler.d.ts} +0 -0
  136. /package/build/src/Handlers/{MetadataHandler.d.ts → SwaggerHandler.d.ts} +0 -0
@@ -1,14 +1,100 @@
1
- import connect from "connect";
2
- import { DynamicFunctionType } from "../Types";
1
+ import connect, { NextHandleFunction, ErrorHandleFunction } from "connect";
2
+ import { GeneralFunction } from "../Types";
3
3
  declare class App {
4
4
  private connect;
5
+ private docs;
5
6
  constructor();
7
+ /**
8
+ * Get the `connect` instance
9
+ *
10
+ * @readonly
11
+ * @memberof App
12
+ */
6
13
  get instance(): connect.Server;
7
- use(middleware: connect.NextHandleFunction): void;
8
- get(url: string, ...args: DynamicFunctionType): void;
9
- post(url: string, ...args: DynamicFunctionType): void;
10
- put(url: string, ...args: DynamicFunctionType): void;
11
- patch(url: string, ...args: DynamicFunctionType): void;
12
- delete(url: string, ...args: DynamicFunctionType): void;
14
+ /**
15
+ * Add a global connect middleware
16
+ *
17
+ * @param middleware
18
+ * @example
19
+ * app.use((req: IncomingMessage, res: ServerResponse, next: any) => {
20
+ * next()
21
+ * })
22
+ */
23
+ use(middleware: NextHandleFunction | ErrorHandleFunction): void;
24
+ /**
25
+ * Add a GET request handler with middleware support
26
+ *
27
+ * @param url
28
+ * @param args
29
+ * @example
30
+ * app.get(
31
+ * "/api/v1/health",
32
+ * myHandler,
33
+ * async (req: AxeRequest, res: AxeResponse) => {
34
+ * res.json({});
35
+ * }
36
+ * );
37
+ */
38
+ get(url: string, ...args: GeneralFunction[]): void;
39
+ /**
40
+ * Add a POST request handler with middleware support
41
+ *
42
+ * @param url
43
+ * @param args
44
+ * @example
45
+ * app.post(
46
+ * "/api/v1/health",
47
+ * myHandler,
48
+ * async (req: AxeRequest, res: AxeResponse) => {
49
+ * res.json({});
50
+ * }
51
+ * );
52
+ */
53
+ post(url: string, ...args: GeneralFunction[]): void;
54
+ /**
55
+ * Add a PUT request handler with middleware support
56
+ *
57
+ * @param url
58
+ * @param args
59
+ * @example
60
+ * app.put(
61
+ * "/api/v1/health",
62
+ * myHandler,
63
+ * async (req: AxeRequest, res: AxeResponse) => {
64
+ * res.json({});
65
+ * }
66
+ * );
67
+ */
68
+ put(url: string, ...args: GeneralFunction[]): void;
69
+ /**
70
+ * Add a PATCH request handler with middleware support
71
+ *
72
+ * @param url
73
+ * @param args
74
+ * @example
75
+ * app.patch(
76
+ * "/api/v1/health",
77
+ * myHandler,
78
+ * async (req: AxeRequest, res: AxeResponse) => {
79
+ * res.json({});
80
+ * }
81
+ * );
82
+ */
83
+ patch(url: string, ...args: GeneralFunction[]): void;
84
+ /**
85
+ * Add a DELETE request handler with middleware support
86
+ *
87
+ * @param url
88
+ * @param args
89
+ * @example
90
+ * app.delete(
91
+ * "/api/v1/health",
92
+ * myHandler,
93
+ * async (req: AxeRequest, res: AxeResponse) => {
94
+ * res.json({});
95
+ * }
96
+ * );
97
+ */
98
+ delete(url: string, ...args: GeneralFunction[]): void;
13
99
  }
14
100
  export default App;
@@ -1,27 +1,4 @@
1
1
  "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || function (mod) {
19
- if (mod && mod.__esModule) return mod;
20
- var result = {};
21
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
- __setModuleDefault(result, mod);
23
- return result;
24
- };
25
2
  var __importDefault = (this && this.__importDefault) || function (mod) {
26
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
27
4
  };
@@ -30,12 +7,14 @@ const connect_1 = __importDefault(require("connect"));
30
7
  const body_parser_1 = __importDefault(require("body-parser"));
31
8
  const URLService_1 = __importDefault(require("./URLService"));
32
9
  const LogService_1 = __importDefault(require("./LogService"));
33
- const RateLimit_1 = __importStar(require("../Middlewares/RateLimit"));
10
+ const RateLimit_1 = require("../Middlewares/RateLimit");
34
11
  const APIService_1 = __importDefault(require("./APIService"));
35
12
  const ConverterService_1 = require("./ConverterService");
13
+ const DocumentationService_1 = __importDefault(require("./DocumentationService"));
14
+ const Enums_1 = require("../Enums");
36
15
  class App {
37
16
  constructor() {
38
- var _a;
17
+ this.docs = DocumentationService_1.default.getInstance();
39
18
  this.connect = (0, connect_1.default)();
40
19
  LogService_1.default.debug("Created a new connect() instance");
41
20
  this.connect.use(body_parser_1.default.urlencoded({ extended: true }));
@@ -44,37 +23,123 @@ class App {
44
23
  // Activate the Rate Limit middleware
45
24
  const api = APIService_1.default.getInstance();
46
25
  (0, RateLimit_1.setupRateLimitAdaptors)(api.config);
47
- if ((_a = api.config.rateLimit) === null || _a === void 0 ? void 0 : _a.enabled) {
48
- LogService_1.default.debug("New middleware: rateLimit()");
49
- this.connect.use(RateLimit_1.default);
50
- }
51
26
  }
27
+ /**
28
+ * Get the `connect` instance
29
+ *
30
+ * @readonly
31
+ * @memberof App
32
+ */
52
33
  get instance() {
53
34
  return this.connect;
54
35
  }
36
+ /**
37
+ * Add a global connect middleware
38
+ *
39
+ * @param middleware
40
+ * @example
41
+ * app.use((req: IncomingMessage, res: ServerResponse, next: any) => {
42
+ * next()
43
+ * })
44
+ */
55
45
  use(middleware) {
56
46
  this.connect.use(middleware);
57
47
  LogService_1.default.debug(`New middleware: ${middleware.name || "anonymous"}()`);
58
48
  }
49
+ /**
50
+ * Add a GET request handler with middleware support
51
+ *
52
+ * @param url
53
+ * @param args
54
+ * @example
55
+ * app.get(
56
+ * "/api/v1/health",
57
+ * myHandler,
58
+ * async (req: AxeRequest, res: AxeResponse) => {
59
+ * res.json({});
60
+ * }
61
+ * );
62
+ */
59
63
  get(url, ...args) {
60
64
  const { handler, middlewares } = (0, ConverterService_1.resolveMiddlewares)(args);
61
65
  URLService_1.default.addHandler("GET", url, handler, middlewares);
66
+ this.docs.pushCustom(Enums_1.HttpMethods.GET, url);
62
67
  }
68
+ /**
69
+ * Add a POST request handler with middleware support
70
+ *
71
+ * @param url
72
+ * @param args
73
+ * @example
74
+ * app.post(
75
+ * "/api/v1/health",
76
+ * myHandler,
77
+ * async (req: AxeRequest, res: AxeResponse) => {
78
+ * res.json({});
79
+ * }
80
+ * );
81
+ */
63
82
  post(url, ...args) {
64
83
  const { handler, middlewares } = (0, ConverterService_1.resolveMiddlewares)(args);
65
84
  URLService_1.default.addHandler("POST", url, handler, middlewares);
85
+ this.docs.pushCustom(Enums_1.HttpMethods.POST, url);
66
86
  }
87
+ /**
88
+ * Add a PUT request handler with middleware support
89
+ *
90
+ * @param url
91
+ * @param args
92
+ * @example
93
+ * app.put(
94
+ * "/api/v1/health",
95
+ * myHandler,
96
+ * async (req: AxeRequest, res: AxeResponse) => {
97
+ * res.json({});
98
+ * }
99
+ * );
100
+ */
67
101
  put(url, ...args) {
68
102
  const { handler, middlewares } = (0, ConverterService_1.resolveMiddlewares)(args);
69
103
  URLService_1.default.addHandler("PUT", url, handler, middlewares);
104
+ this.docs.pushCustom(Enums_1.HttpMethods.PUT, url);
70
105
  }
106
+ /**
107
+ * Add a PATCH request handler with middleware support
108
+ *
109
+ * @param url
110
+ * @param args
111
+ * @example
112
+ * app.patch(
113
+ * "/api/v1/health",
114
+ * myHandler,
115
+ * async (req: AxeRequest, res: AxeResponse) => {
116
+ * res.json({});
117
+ * }
118
+ * );
119
+ */
71
120
  patch(url, ...args) {
72
121
  const { handler, middlewares } = (0, ConverterService_1.resolveMiddlewares)(args);
73
122
  URLService_1.default.addHandler("PATCH", url, handler, middlewares);
123
+ this.docs.pushCustom(Enums_1.HttpMethods.PATCH, url);
74
124
  }
125
+ /**
126
+ * Add a DELETE request handler with middleware support
127
+ *
128
+ * @param url
129
+ * @param args
130
+ * @example
131
+ * app.delete(
132
+ * "/api/v1/health",
133
+ * myHandler,
134
+ * async (req: AxeRequest, res: AxeResponse) => {
135
+ * res.json({});
136
+ * }
137
+ * );
138
+ */
75
139
  delete(url, ...args) {
76
140
  const { handler, middlewares } = (0, ConverterService_1.resolveMiddlewares)(args);
77
141
  URLService_1.default.addHandler("DELETE", url, handler, middlewares);
142
+ this.docs.pushCustom(Enums_1.HttpMethods.DELETE, url);
78
143
  }
79
144
  }
80
145
  exports.default = App;
@@ -10,17 +10,66 @@ declare class AxeRequest {
10
10
  private privateParams;
11
11
  private version;
12
12
  constructor(request: IncomingMessage);
13
+ /**
14
+ * Get the URL Object
15
+ *
16
+ * @memberof AxeRequest
17
+ */
13
18
  get url(): URL;
19
+ /**
20
+ * Get the URL params
21
+ *
22
+ * @memberof AxeRequest
23
+ * @example
24
+ * GET api/v1/users/123
25
+ * { "id": 123 }
26
+ */
14
27
  get params(): any;
15
28
  set params(value: any);
29
+ /**
30
+ * Get the URLSearchParams
31
+ *
32
+ * @memberof AxeRequest
33
+ */
16
34
  get query(): URLSearchParams;
17
- get path(): string;
35
+ /**
36
+ * Get the HTTP Method
37
+ *
38
+ * @memberof AxeRequest
39
+ */
18
40
  get method(): string;
41
+ /**
42
+ * Get the request form body
43
+ *
44
+ * @memberof AxeRequest
45
+ */
19
46
  get body(): any;
47
+ /**
48
+ * Get the current langugage
49
+ *
50
+ * @memberof AxeRequest
51
+ */
20
52
  get currentLanguage(): ILanguage;
21
53
  set currentLanguage(language: ILanguage);
54
+ /**
55
+ * Get a HTTP Request Header value
56
+ *
57
+ * @param key
58
+ * @returns
59
+ */
22
60
  header(key: string): string | string[] | undefined;
23
- files(options?: FormOptions): Promise<[formidable.Fields, formidable.Files]>;
61
+ /**
62
+ * Parse and get uploaded files. It uses `formidable` internally.
63
+ *
64
+ * @param options
65
+ * @returns
66
+ */
67
+ files(options?: FormOptions): Promise<[formidable.Fields<string>, formidable.Files<string>]>;
68
+ /**
69
+ * Get the original `IncomingMessage` request.
70
+ *
71
+ * @memberof AxeRequest
72
+ */
24
73
  get original(): IncomingMessage;
25
74
  }
26
75
  export default AxeRequest;
@@ -20,6 +20,7 @@ class AxeRequest {
20
20
  constructor(request) {
21
21
  this.privateParams = {};
22
22
  this.request = request;
23
+ this.request.tags = [];
23
24
  this.urlObject = new URL(request.url || "", "http://127.0.0.1");
24
25
  // Application configuration is need for the default setting.
25
26
  this.version = (0, Helpers_1.getVersionByRequest)(this.urlObject);
@@ -35,37 +36,78 @@ class AxeRequest {
35
36
  };
36
37
  }
37
38
  }
39
+ /**
40
+ * Get the URL Object
41
+ *
42
+ * @memberof AxeRequest
43
+ */
38
44
  get url() {
39
45
  return this.urlObject;
40
46
  }
47
+ /**
48
+ * Get the URL params
49
+ *
50
+ * @memberof AxeRequest
51
+ * @example
52
+ * GET api/v1/users/123
53
+ * { "id": 123 }
54
+ */
41
55
  get params() {
42
56
  return this.privateParams;
43
57
  }
44
58
  set params(value) {
45
59
  this.privateParams = value;
46
60
  }
61
+ /**
62
+ * Get the URLSearchParams
63
+ *
64
+ * @memberof AxeRequest
65
+ */
47
66
  get query() {
48
67
  return this.urlObject.searchParams;
49
68
  }
50
- get path() {
51
- // TODO: Path
52
- return this.request.url || "";
53
- }
69
+ /**
70
+ * Get the HTTP Method
71
+ *
72
+ * @memberof AxeRequest
73
+ */
54
74
  get method() {
55
75
  return this.request.method || "GET";
56
76
  }
77
+ /**
78
+ * Get the request form body
79
+ *
80
+ * @memberof AxeRequest
81
+ */
57
82
  get body() {
58
83
  return this.request.body;
59
84
  }
85
+ /**
86
+ * Get the current langugage
87
+ *
88
+ * @memberof AxeRequest
89
+ */
60
90
  get currentLanguage() {
61
91
  return this.language;
62
92
  }
63
93
  set currentLanguage(language) {
64
94
  this.language = language;
65
95
  }
96
+ /**
97
+ * Get a HTTP Request Header value
98
+ *
99
+ * @param key
100
+ * @returns
101
+ */
66
102
  header(key) {
67
103
  return this.request.headers[key];
68
104
  }
105
+ /**
106
+ * Parse and get uploaded files. It uses `formidable` internally.
107
+ *
108
+ * @param options
109
+ * @returns
110
+ */
69
111
  files(options) {
70
112
  var _a, _b;
71
113
  return __awaiter(this, void 0, void 0, function* () {
@@ -78,6 +120,11 @@ class AxeRequest {
78
120
  return yield form.parse(this.request);
79
121
  });
80
122
  }
123
+ /**
124
+ * Get the original `IncomingMessage` request.
125
+ *
126
+ * @memberof AxeRequest
127
+ */
81
128
  get original() {
82
129
  return this.request;
83
130
  }
@@ -1,18 +1,45 @@
1
1
  /// <reference types="node" />
2
2
  /// <reference types="express" />
3
3
  import { ServerResponse } from "http";
4
+ import { StatusCodes } from "src/Enums";
4
5
  import { ILanguage } from "src/Interfaces";
5
6
  declare class AxeResponse {
6
7
  private response;
7
8
  private responseStatus;
8
9
  private language;
9
10
  constructor(response: ServerResponse, language: ILanguage);
11
+ /**
12
+ * Get the original `ServerResponse` value
13
+ *
14
+ * @readonly
15
+ * @memberof AxeResponse
16
+ */
10
17
  get original(): ServerResponse<import("http").IncomingMessage>;
11
- status(statusCode: number): this;
18
+ /**
19
+ * Set the HTTP Response Status Code
20
+ *
21
+ * @param statusCode
22
+ * @returns
23
+ */
24
+ status(statusCode: StatusCodes): this;
25
+ /**
26
+ * Set the HTTP Response Data as JSON
27
+ *
28
+ * @param data
29
+ */
12
30
  json(data: object): void;
31
+ /**
32
+ * Set the HTTP Response Data as string
33
+ *
34
+ * @param data
35
+ */
13
36
  send(content: string): void;
37
+ /**
38
+ * Set the no-content to the HTTP Response with 204 status code.
39
+ */
14
40
  noContent(): void;
15
41
  isResponded(): boolean;
16
42
  statusCode(): number;
43
+ header(key: string, value: string): void;
17
44
  }
18
45
  export default AxeResponse;
@@ -7,13 +7,30 @@ class AxeResponse {
7
7
  this.response.statusCode = 200;
8
8
  this.language = language;
9
9
  }
10
+ /**
11
+ * Get the original `ServerResponse` value
12
+ *
13
+ * @readonly
14
+ * @memberof AxeResponse
15
+ */
10
16
  get original() {
11
17
  return this.response;
12
18
  }
19
+ /**
20
+ * Set the HTTP Response Status Code
21
+ *
22
+ * @param statusCode
23
+ * @returns
24
+ */
13
25
  status(statusCode) {
14
26
  this.response.statusCode = statusCode;
15
27
  return this;
16
28
  }
29
+ /**
30
+ * Set the HTTP Response Data as JSON
31
+ *
32
+ * @param data
33
+ */
17
34
  json(data) {
18
35
  this.response.setHeader("Content-Type", "application/json");
19
36
  this.response.setHeader("Content-Language", this.language.language);
@@ -21,11 +38,19 @@ class AxeResponse {
21
38
  this.response.end();
22
39
  this.responseStatus = true;
23
40
  }
41
+ /**
42
+ * Set the HTTP Response Data as string
43
+ *
44
+ * @param data
45
+ */
24
46
  send(content) {
25
47
  this.response.write(content);
26
48
  this.response.end();
27
49
  this.responseStatus = true;
28
50
  }
51
+ /**
52
+ * Set the no-content to the HTTP Response with 204 status code.
53
+ */
29
54
  noContent() {
30
55
  this.response.statusCode = 204;
31
56
  this.response.end();
@@ -37,5 +62,8 @@ class AxeResponse {
37
62
  statusCode() {
38
63
  return this.response.statusCode;
39
64
  }
65
+ header(key, value) {
66
+ this.original.setHeader(key, value);
67
+ }
40
68
  }
41
69
  exports.default = AxeResponse;
@@ -1,9 +1,11 @@
1
+ /// <reference types="node" />
2
+ /// <reference types="express" />
1
3
  import { IncomingMessage, ServerResponse } from "http";
2
4
  import { AxeRequestResponsePair, MiddlewareResolution } from "../Interfaces";
3
- import { DynamicFunctionType, PhaseFunction, StepTypes } from "src/Types";
5
+ import { GeneralFunction, PhaseFunction, AxeFunction } from "src/Types";
4
6
  export declare const toAxeRequestResponsePair: (request: IncomingMessage, response: ServerResponse) => AxeRequestResponsePair;
5
- export declare const resolveMiddlewares: (args: DynamicFunctionType) => MiddlewareResolution;
7
+ export declare const resolveMiddlewares: (args: GeneralFunction[]) => MiddlewareResolution;
6
8
  export declare const isMiddlewareFunction: (callback: any) => boolean;
7
9
  export declare const isHandlerFunction: (callback: any) => boolean;
8
10
  export declare const isPhaseFunction: (callback: any) => boolean;
9
- export declare const toPhaseFunction: (callback: StepTypes) => PhaseFunction;
11
+ export declare const toPhaseFunction: (callback: AxeFunction) => PhaseFunction;
@@ -1,11 +1,14 @@
1
- import { IModelService, IRouteDocumentation, IVersion } from "../Interfaces";
1
+ import { ICustomRouteDocumentation, IModelService, IRouteDocumentation, IVersion } from "../Interfaces";
2
2
  import { HandlerTypes, HttpMethods } from "../Enums";
3
3
  declare class DocumentationService {
4
4
  private static instance;
5
5
  private routes;
6
+ private customRoutes;
6
7
  constructor();
7
8
  static getInstance(): DocumentationService;
8
- push(version: IVersion, handler: HandlerTypes, method: HttpMethods, url: string, model: IModelService): void;
9
+ push(version: IVersion, handler: HandlerTypes, method: HttpMethods, url: string, model: IModelService, parentModel: IModelService | null): void;
10
+ pushCustom(method: HttpMethods, url: string): void;
9
11
  get(): IRouteDocumentation[];
12
+ getCustoms(): ICustomRouteDocumentation[];
10
13
  }
11
14
  export default DocumentationService;
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  class DocumentationService {
4
4
  constructor() {
5
5
  this.routes = [];
6
+ this.customRoutes = [];
6
7
  }
7
8
  static getInstance() {
8
9
  if (!DocumentationService.instance) {
@@ -10,11 +11,13 @@ class DocumentationService {
10
11
  }
11
12
  return DocumentationService.instance;
12
13
  }
13
- push(version, handler, method, url, model) {
14
+ push(version, handler, method, url, model, parentModel) {
14
15
  var _a, _b, _c;
15
16
  this.routes.push({
16
17
  version: version.name,
17
18
  handler,
19
+ modelService: model,
20
+ parentModel,
18
21
  model: model.name,
19
22
  table: model.instance.table,
20
23
  columns: model.columns,
@@ -28,8 +31,17 @@ class DocumentationService {
28
31
  queryDefaults: (_c = (_b = (_a = version.config) === null || _a === void 0 ? void 0 : _a.query) === null || _b === void 0 ? void 0 : _b.defaults) !== null && _c !== void 0 ? _c : {},
29
32
  });
30
33
  }
34
+ pushCustom(method, url) {
35
+ this.customRoutes.push({
36
+ method,
37
+ url,
38
+ });
39
+ }
31
40
  get() {
32
41
  return this.routes;
33
42
  }
43
+ getCustoms() {
44
+ return this.customRoutes;
45
+ }
34
46
  }
35
47
  exports.default = DocumentationService;
@@ -0,0 +1,14 @@
1
+ import { ClientOptions } from "@elastic/elasticsearch";
2
+ import { ISearchConfigutation } from "src/Interfaces";
3
+ declare class ElasticService {
4
+ private config;
5
+ private client;
6
+ constructor(config: ISearchConfigutation, options: ClientOptions);
7
+ createIndex(modelName: string): Promise<void>;
8
+ insert(modelName: string, id: string, body: any): Promise<import("@elastic/elasticsearch/lib/api/types").WriteResponseBase>;
9
+ update(modelName: string, id: string, doc: any): Promise<import("@elastic/elasticsearch/lib/api/types").UpdateResponse<unknown>>;
10
+ delete(modelName: string, id: string): Promise<import("@elastic/elasticsearch/lib/api/types").WriteResponseBase>;
11
+ search(modelName: string, page: number, size: number, body: any): Promise<import("@elastic/elasticsearch/lib/api/types").SearchResponse<unknown, Record<string, import("@elastic/elasticsearch/lib/api/types").AggregationsAggregate>>>;
12
+ private toIndex;
13
+ }
14
+ export default ElasticService;