@expressots/core 1.8.1 → 1.9.1

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 (157) hide show
  1. package/lib/CHANGELOG.md +33 -10
  2. package/lib/cjs/application/application-factory.js +83 -0
  3. package/lib/cjs/application/index.js +3 -5
  4. package/lib/cjs/common/color-service.provider.js +46 -0
  5. package/lib/cjs/common/package-resolver.provider.js +35 -0
  6. package/lib/cjs/console/console.js +10 -33
  7. package/lib/cjs/controller/base-controller.js +1 -14
  8. package/lib/cjs/decorator/scope-binding.js +30 -0
  9. package/lib/cjs/error/report.js +14 -5
  10. package/lib/cjs/index.js +2 -2
  11. package/lib/cjs/middleware/index.js +5 -0
  12. package/lib/cjs/middleware/interfaces/body-parser.interface.js +2 -0
  13. package/lib/cjs/middleware/interfaces/compression.interface.js +2 -0
  14. package/lib/cjs/middleware/interfaces/cors.interface.js +2 -0
  15. package/lib/cjs/middleware/interfaces/serve-static.interface.js +2 -0
  16. package/lib/cjs/middleware/middleware-resolver.js +67 -0
  17. package/lib/cjs/middleware/middleware-service.js +145 -0
  18. package/lib/cjs/provider/dto-validator/dto-validator.provider.js +62 -0
  19. package/lib/cjs/{environment/env-validator.js → provider/environment/env-validator.provider.js} +16 -10
  20. package/lib/cjs/provider/index.js +11 -0
  21. package/lib/cjs/provider/logger/logger-service.js +114 -0
  22. package/lib/cjs/provider/provider-service.js +36 -0
  23. package/lib/cjs/types/application/application-factory.d.ts +34 -0
  24. package/lib/cjs/types/application/application-factory.d.ts.map +1 -0
  25. package/lib/cjs/types/application/index.d.ts +1 -1
  26. package/lib/cjs/types/application/index.d.ts.map +1 -1
  27. package/lib/cjs/types/common/color-service.provider.d.ts +30 -0
  28. package/lib/cjs/types/common/color-service.provider.d.ts.map +1 -0
  29. package/lib/cjs/types/common/package-resolver.provider.d.ts +9 -0
  30. package/lib/cjs/types/common/package-resolver.provider.d.ts.map +1 -0
  31. package/lib/cjs/types/console/console.d.ts +1 -1
  32. package/lib/cjs/types/console/console.d.ts.map +1 -1
  33. package/lib/cjs/types/controller/base-controller.d.ts +4 -10
  34. package/lib/cjs/types/controller/base-controller.d.ts.map +1 -1
  35. package/lib/cjs/types/decorator/scope-binding.d.ts +30 -0
  36. package/lib/cjs/types/decorator/scope-binding.d.ts.map +1 -1
  37. package/lib/cjs/types/error/report.d.ts +5 -3
  38. package/lib/cjs/types/error/report.d.ts.map +1 -1
  39. package/lib/cjs/types/index.d.ts +2 -2
  40. package/lib/cjs/types/index.d.ts.map +1 -1
  41. package/lib/cjs/types/middleware/index.d.ts +5 -0
  42. package/lib/cjs/types/middleware/index.d.ts.map +1 -0
  43. package/lib/cjs/types/middleware/interfaces/body-parser.interface.d.ts +34 -0
  44. package/lib/cjs/types/middleware/interfaces/body-parser.interface.d.ts.map +1 -0
  45. package/lib/cjs/types/middleware/interfaces/compression.interface.d.ts +99 -0
  46. package/lib/cjs/types/middleware/interfaces/compression.interface.d.ts.map +1 -0
  47. package/lib/cjs/types/middleware/interfaces/cors.interface.d.ts +58 -0
  48. package/lib/cjs/types/middleware/interfaces/cors.interface.d.ts.map +1 -0
  49. package/lib/cjs/types/middleware/interfaces/serve-static.interface.d.ts +71 -0
  50. package/lib/cjs/types/middleware/interfaces/serve-static.interface.d.ts.map +1 -0
  51. package/lib/cjs/types/middleware/middleware-resolver.d.ts +12 -0
  52. package/lib/cjs/types/middleware/middleware-resolver.d.ts.map +1 -0
  53. package/lib/cjs/types/middleware/middleware-service.d.ts +137 -0
  54. package/lib/cjs/types/middleware/middleware-service.d.ts.map +1 -0
  55. package/lib/cjs/types/provider/dto-validator/dto-validator.provider.d.ts +12 -0
  56. package/lib/cjs/types/provider/dto-validator/dto-validator.provider.d.ts.map +1 -0
  57. package/lib/cjs/types/{environment/env-validator.d.ts → provider/environment/env-validator.provider.d.ts} +7 -4
  58. package/lib/cjs/types/provider/environment/env-validator.provider.d.ts.map +1 -0
  59. package/lib/cjs/types/provider/index.d.ts +5 -0
  60. package/lib/cjs/types/provider/index.d.ts.map +1 -0
  61. package/lib/cjs/types/provider/logger/logger-service.d.ts +50 -0
  62. package/lib/cjs/types/provider/logger/logger-service.d.ts.map +1 -0
  63. package/lib/{esm/types/logger/general-logger.d.ts → cjs/types/provider/logger/winston-logger.d.ts} +1 -1
  64. package/lib/cjs/types/provider/logger/winston-logger.d.ts.map +1 -0
  65. package/lib/cjs/types/provider/provider-service.d.ts +31 -0
  66. package/lib/cjs/types/provider/provider-service.d.ts.map +1 -0
  67. package/lib/esm/application/application-factory.js +72 -0
  68. package/lib/esm/application/index.js +3 -5
  69. package/lib/esm/common/color-service.provider.js +46 -0
  70. package/lib/esm/common/package-resolver.provider.js +35 -0
  71. package/lib/esm/console/console.js +10 -33
  72. package/lib/esm/controller/base-controller.js +1 -15
  73. package/lib/esm/decorator/scope-binding.js +30 -0
  74. package/lib/esm/error/report.js +15 -5
  75. package/lib/esm/index.mjs +2 -2
  76. package/lib/esm/middleware/index.js +5 -0
  77. package/lib/esm/middleware/interfaces/body-parser.interface.js +2 -0
  78. package/lib/esm/middleware/interfaces/compression.interface.js +2 -0
  79. package/lib/esm/middleware/interfaces/cors.interface.js +2 -0
  80. package/lib/esm/middleware/interfaces/serve-static.interface.js +2 -0
  81. package/lib/esm/middleware/middleware-resolver.js +68 -0
  82. package/lib/esm/middleware/middleware-service.js +144 -0
  83. package/lib/esm/provider/dto-validator/dto-validator.provider.js +53 -0
  84. package/lib/esm/{environment/env-validator.js → provider/environment/env-validator.provider.js} +17 -10
  85. package/lib/esm/provider/index.js +11 -0
  86. package/lib/esm/provider/logger/logger-service.js +115 -0
  87. package/lib/esm/provider/provider-service.js +38 -0
  88. package/lib/esm/types/application/application-factory.d.ts +34 -0
  89. package/lib/esm/types/application/application-factory.d.ts.map +1 -0
  90. package/lib/esm/types/application/index.d.ts +1 -1
  91. package/lib/esm/types/application/index.d.ts.map +1 -1
  92. package/lib/esm/types/common/color-service.provider.d.ts +30 -0
  93. package/lib/esm/types/common/color-service.provider.d.ts.map +1 -0
  94. package/lib/esm/types/common/package-resolver.provider.d.ts +9 -0
  95. package/lib/esm/types/common/package-resolver.provider.d.ts.map +1 -0
  96. package/lib/esm/types/console/console.d.ts +1 -1
  97. package/lib/esm/types/console/console.d.ts.map +1 -1
  98. package/lib/esm/types/controller/base-controller.d.ts +4 -10
  99. package/lib/esm/types/controller/base-controller.d.ts.map +1 -1
  100. package/lib/esm/types/decorator/scope-binding.d.ts +30 -0
  101. package/lib/esm/types/decorator/scope-binding.d.ts.map +1 -1
  102. package/lib/esm/types/error/report.d.ts +5 -3
  103. package/lib/esm/types/error/report.d.ts.map +1 -1
  104. package/lib/esm/types/index.d.ts +2 -2
  105. package/lib/esm/types/index.d.ts.map +1 -1
  106. package/lib/esm/types/middleware/index.d.ts +5 -0
  107. package/lib/esm/types/middleware/index.d.ts.map +1 -0
  108. package/lib/esm/types/middleware/interfaces/body-parser.interface.d.ts +34 -0
  109. package/lib/esm/types/middleware/interfaces/body-parser.interface.d.ts.map +1 -0
  110. package/lib/esm/types/middleware/interfaces/compression.interface.d.ts +99 -0
  111. package/lib/esm/types/middleware/interfaces/compression.interface.d.ts.map +1 -0
  112. package/lib/esm/types/middleware/interfaces/cors.interface.d.ts +58 -0
  113. package/lib/esm/types/middleware/interfaces/cors.interface.d.ts.map +1 -0
  114. package/lib/esm/types/middleware/interfaces/serve-static.interface.d.ts +71 -0
  115. package/lib/esm/types/middleware/interfaces/serve-static.interface.d.ts.map +1 -0
  116. package/lib/esm/types/middleware/middleware-resolver.d.ts +12 -0
  117. package/lib/esm/types/middleware/middleware-resolver.d.ts.map +1 -0
  118. package/lib/esm/types/middleware/middleware-service.d.ts +137 -0
  119. package/lib/esm/types/middleware/middleware-service.d.ts.map +1 -0
  120. package/lib/esm/types/provider/dto-validator/dto-validator.provider.d.ts +12 -0
  121. package/lib/esm/types/provider/dto-validator/dto-validator.provider.d.ts.map +1 -0
  122. package/lib/esm/types/{environment/env-validator.d.ts → provider/environment/env-validator.provider.d.ts} +7 -4
  123. package/lib/esm/types/provider/environment/env-validator.provider.d.ts.map +1 -0
  124. package/lib/esm/types/provider/index.d.ts +5 -0
  125. package/lib/esm/types/provider/index.d.ts.map +1 -0
  126. package/lib/esm/types/provider/logger/logger-service.d.ts +50 -0
  127. package/lib/esm/types/provider/logger/logger-service.d.ts.map +1 -0
  128. package/lib/{cjs/types/logger/general-logger.d.ts → esm/types/provider/logger/winston-logger.d.ts} +1 -1
  129. package/lib/esm/types/provider/logger/winston-logger.d.ts.map +1 -0
  130. package/lib/esm/types/provider/provider-service.d.ts +31 -0
  131. package/lib/esm/types/provider/provider-service.d.ts.map +1 -0
  132. package/lib/package.json +7 -4
  133. package/package.json +7 -4
  134. package/lib/cjs/application/application.js +0 -141
  135. package/lib/cjs/environment/index.js +0 -5
  136. package/lib/cjs/logger/index.js +0 -7
  137. package/lib/cjs/types/application/application.d.ts +0 -70
  138. package/lib/cjs/types/application/application.d.ts.map +0 -1
  139. package/lib/cjs/types/environment/env-validator.d.ts.map +0 -1
  140. package/lib/cjs/types/environment/index.d.ts +0 -2
  141. package/lib/cjs/types/environment/index.d.ts.map +0 -1
  142. package/lib/cjs/types/logger/general-logger.d.ts.map +0 -1
  143. package/lib/cjs/types/logger/index.d.ts +0 -2
  144. package/lib/cjs/types/logger/index.d.ts.map +0 -1
  145. package/lib/esm/application/application.js +0 -144
  146. package/lib/esm/environment/index.js +0 -5
  147. package/lib/esm/logger/index.js +0 -7
  148. package/lib/esm/types/application/application.d.ts +0 -70
  149. package/lib/esm/types/application/application.d.ts.map +0 -1
  150. package/lib/esm/types/environment/env-validator.d.ts.map +0 -1
  151. package/lib/esm/types/environment/index.d.ts +0 -2
  152. package/lib/esm/types/environment/index.d.ts.map +0 -1
  153. package/lib/esm/types/logger/general-logger.d.ts.map +0 -1
  154. package/lib/esm/types/logger/index.d.ts +0 -2
  155. package/lib/esm/types/logger/index.d.ts.map +0 -1
  156. /package/lib/cjs/{logger/general-logger.js → provider/logger/winston-logger.js} +0 -0
  157. /package/lib/esm/{logger/general-logger.js → provider/logger/winston-logger.js} +0 -0
@@ -6,19 +6,21 @@ import { AppError } from "./app-error";
6
6
  */
7
7
  declare class Report {
8
8
  static stack: string;
9
+ private logger;
10
+ constructor();
9
11
  /**
10
12
  * The Error method is responsible for generating a standardized error object,
11
13
  * logging the error, and then throwing it for further handling.
12
- * The error thrown is of the custom type IAppError, which extends the built-in Error class.
14
+ * The error thrown is of the custom type AppError, which extends the built-in Error class.
13
15
  *
14
16
  * @param error - An instance of Error or a string that describes the error.
15
17
  * @param statusCode - The HTTP status code associated with the error (default is 500).
16
18
  * @param service - The service name associated with the error. If not specified,
17
19
  * it defaults to the name of the calling function.
18
20
  *
19
- * @throws An object of the custom type IAppError, which includes details about the error.
21
+ * @throws An object of the custom type AppError, which includes details about the error.
20
22
  */
21
- Error(error: Error | string, statusCode?: number, service?: string): AppError;
23
+ error(error: Error | string, statusCode?: number, service?: string): AppError;
22
24
  }
23
25
  export { Report };
24
26
  //# sourceMappingURL=report.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"report.d.ts","sourceRoot":"","sources":["../../../../packages/core/src/error/report.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAEvC;;;;GAIG;AACH,cACM,MAAM;IACV,MAAM,CAAC,KAAK,EAAE,MAAM,CAAC;IAErB;;;;;;;;;;;OAWG;IACI,KAAK,CACV,KAAK,EAAE,KAAK,GAAG,MAAM,EACrB,UAAU,CAAC,EAAE,MAAM,EACnB,OAAO,CAAC,EAAE,MAAM,GACf,QAAQ;CAWZ;AAED,OAAO,EAAE,MAAM,EAAE,CAAC"}
1
+ {"version":3,"file":"report.d.ts","sourceRoot":"","sources":["../../../../packages/core/src/error/report.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAEvC;;;;GAIG;AACH,cACM,MAAM;IACV,MAAM,CAAC,KAAK,EAAE,MAAM,CAAC;IACrB,OAAO,CAAC,MAAM,CAAS;;IAMvB;;;;;;;;;;;OAWG;IACI,KAAK,CACV,KAAK,EAAE,KAAK,GAAG,MAAM,EACrB,UAAU,CAAC,EAAE,MAAM,EACnB,OAAO,CAAC,EAAE,MAAM,GACf,QAAQ;CAgBZ;AAED,OAAO,EAAE,MAAM,EAAE,CAAC"}
@@ -4,8 +4,8 @@ export * from "./console";
4
4
  export * from "./container-module";
5
5
  export * from "./controller";
6
6
  export * from "./decorator";
7
- export * from "./environment";
8
7
  export * from "./error";
9
- export * from "./logger";
8
+ export * from "./middleware";
9
+ export * from "./provider";
10
10
  export * from "./render";
11
11
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../packages/core/src/index.ts"],"names":[],"mappings":"AAAA,cAAc,eAAe,CAAC;AAC9B,cAAc,UAAU,CAAC;AACzB,cAAc,WAAW,CAAC;AAC1B,cAAc,oBAAoB,CAAC;AACnC,cAAc,cAAc,CAAC;AAC7B,cAAc,aAAa,CAAC;AAC5B,cAAc,eAAe,CAAC;AAC9B,cAAc,SAAS,CAAC;AACxB,cAAc,UAAU,CAAC;AACzB,cAAc,UAAU,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../packages/core/src/index.ts"],"names":[],"mappings":"AAAA,cAAc,eAAe,CAAC;AAC9B,cAAc,UAAU,CAAC;AACzB,cAAc,WAAW,CAAC;AAC1B,cAAc,oBAAoB,CAAC;AACnC,cAAc,cAAc,CAAC;AAC7B,cAAc,aAAa,CAAC;AAC5B,cAAc,SAAS,CAAC;AACxB,cAAc,cAAc,CAAC;AAC7B,cAAc,YAAY,CAAC;AAC3B,cAAc,UAAU,CAAC"}
@@ -0,0 +1,5 @@
1
+ export { IMiddleware, Middleware } from "./middleware-service";
2
+ export { OptionsJson } from "./interfaces/body-parser.interface";
3
+ export { CorsOptions } from "./interfaces/cors.interface";
4
+ export { CompressionOptions } from "./interfaces/compression.interface";
5
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../packages/core/src/middleware/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAC/D,OAAO,EAAE,WAAW,EAAE,MAAM,oCAAoC,CAAC;AACjE,OAAO,EAAE,WAAW,EAAE,MAAM,6BAA6B,CAAC;AAC1D,OAAO,EAAE,kBAAkB,EAAE,MAAM,oCAAoC,CAAC"}
@@ -0,0 +1,34 @@
1
+ /// <reference types="node" />
2
+ /// <reference types="node" />
3
+ import * as http from "http";
4
+ interface OptionsJson {
5
+ /** When set to true, then deflated (compressed) bodies will be inflated; when false, deflated bodies are rejected. Defaults to true. */
6
+ inflate?: boolean | undefined;
7
+ /**
8
+ * Controls the maximum request body size. If this is a number,
9
+ * then the value specifies the number of bytes; if it is a string,
10
+ * the value is passed to the bytes library for parsing. Defaults to '100kb'.
11
+ */
12
+ limit?: number | string | undefined;
13
+ /**
14
+ * The type option is used to determine what media type the middleware will parse
15
+ */
16
+ type?: string | Array<string> | ((req: http.IncomingMessage) => any) | undefined;
17
+ /**
18
+ * The verify option, if supplied, is called as verify(req, res, buf, encoding),
19
+ * where buf is a Buffer of the raw request body and encoding is the encoding of the request.
20
+ */
21
+ verify?(req: http.IncomingMessage, res: http.ServerResponse, buf: Buffer, encoding: string): void;
22
+ /**
23
+ *
24
+ * The reviver option is passed directly to JSON.parse as the second argument.
25
+ */
26
+ reviver?(key: string, value: any): any;
27
+ /**
28
+ * When set to `true`, will only accept arrays and objects;
29
+ * when `false` will accept anything JSON.parse accepts. Defaults to `true`.
30
+ */
31
+ strict?: boolean | undefined;
32
+ }
33
+ export { OptionsJson };
34
+ //# sourceMappingURL=body-parser.interface.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"body-parser.interface.d.ts","sourceRoot":"","sources":["../../../../../packages/core/src/middleware/interfaces/body-parser.interface.ts"],"names":[],"mappings":";;AACA,OAAO,KAAK,IAAI,MAAM,MAAM,CAAC;AAE7B,UAAU,WAAW;IACnB,wIAAwI;IACxI,OAAO,CAAC,EAAE,OAAO,GAAG,SAAS,CAAC;IAC9B;;;;OAIG;IACH,KAAK,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAAC;IACpC;;OAEG;IACH,IAAI,CAAC,EACD,MAAM,GACN,KAAK,CAAC,MAAM,CAAC,GACb,CAAC,CAAC,GAAG,EAAE,IAAI,CAAC,eAAe,KAAK,GAAG,CAAC,GACpC,SAAS,CAAC;IACd;;;OAGG;IACH,MAAM,CAAC,CACL,GAAG,EAAE,IAAI,CAAC,eAAe,EACzB,GAAG,EAAE,IAAI,CAAC,cAAc,EACxB,GAAG,EAAE,MAAM,EACX,QAAQ,EAAE,MAAM,GACf,IAAI,CAAC;IACR;;;OAGG;IACH,OAAO,CAAC,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,GAAG,GAAG,GAAG,CAAC;IACvC;;;OAGG;IACH,MAAM,CAAC,EAAE,OAAO,GAAG,SAAS,CAAC;CAC9B;AAED,OAAO,EAAE,WAAW,EAAE,CAAC"}
@@ -0,0 +1,99 @@
1
+ import express from "express";
2
+ interface CompressionFilter {
3
+ (req: express.Request, res: express.Response): boolean;
4
+ }
5
+ interface CompressionOptions {
6
+ /**
7
+ * @default zlib.constants.Z_DEFAULT_CHUNK or 16384
8
+ * @see {@link https://nodejs.org/api/zlib.html#zlib_memory_usage_tuning| Node.js documentation}
9
+ * @see {@link https://github.com/expressjs/compression#chunksize|chunkSize documentation}
10
+ */
11
+ chunkSize?: number | undefined;
12
+ /**
13
+ * A function to decide if the response should be considered for compression. This function is called as
14
+ * `filter(req, res)` and is expected to return `true` to consider the response for compression, or `false` to
15
+ * not compress the response.
16
+ *
17
+ * The default filter function uses the `compressible` module to determine if `res.getHeader('Content-Type')`
18
+ * is compressible.
19
+ *
20
+ * @see {@link https://github.com/expressjs/compression#filter|`filter` documentation}
21
+ * @see {@link https://www.npmjs.com/package/compressible|compressible module}
22
+ */
23
+ filter?: CompressionFilter | undefined;
24
+ /**
25
+ * The level of zlib compression to apply to responses. A higher level will result in better compression, but
26
+ * will take longer to complete. A lower level will result in less compression, but will be much faster.
27
+ *
28
+ * This is an integer in the range of `0` (no compression) to `9` (maximum compression). The special value `-1`
29
+ * can be used to mean the "default compression level", which is a default compromise between speed and
30
+ * compression (currently equivalent to level 6).
31
+ *
32
+ * - `-1` Default compression level (also `zlib.constants.Z_DEFAULT_COMPRESSION`).
33
+ * - `0` No compression (also `zlib.constants.Z_NO_COMPRESSION`).
34
+ * - `1` Fastest compression (also `zlib.constants.Z_BEST_SPEED`).
35
+ * - `2`
36
+ * - `3`
37
+ * - `4`
38
+ * - `5`
39
+ * - `6` (currently what `zlib.constants.Z_DEFAULT_COMPRESSION` points to).
40
+ * - `7`
41
+ * - `8`
42
+ * - `9` Best compression (also `zlib.constants.Z_BEST_COMPRESSION`).
43
+ *
44
+ * **Note** in the list above, `zlib` is from `zlib = require('zlib')`.
45
+ *
46
+ * @default zlib.constants.DEFAULT_COMPRESSION or -1
47
+ * @see {@link https://github.com/expressjs/compression#level|`level` documentation}
48
+ */
49
+ level?: number | undefined;
50
+ /**
51
+ * This specifies how much memory should be allocated for the internal compression state and is an integer in
52
+ * the range of `1` (minimum level) and `9` (maximum level).
53
+ *
54
+ * @default zlib.constants.DEFAULT_MEMLEVEL or 8
55
+ * @see {@link https://nodejs.org/api/zlib.html#zlib_memory_usage_tuning|Node.js documentation}
56
+ * @see {@link https://github.com/expressjs/compression#memlevel|`memLevel` documentation}
57
+ */
58
+ memLevel?: number | undefined;
59
+ /**
60
+ * This is used to tune the compression algorithm. This value only affects the compression ratio, not the
61
+ * correctness of the compressed output, even if it is not set appropriately.
62
+ *
63
+ * - `zlib.constants.Z_DEFAULT_STRATEGY` Use for normal data.
64
+ * - `zlib.constants.Z_FILTERED` Use for data produced by a filter (or predictor). Filtered data consists mostly of small
65
+ * values with a somewhat random distribution. In this case, the compression algorithm is tuned to compress
66
+ * them better. The effect is to force more Huffman coding and less string matching; it is somewhat intermediate
67
+ * between `zlib.constants.Z_DEFAULT_STRATEGY` and `zlib.constants.Z_HUFFMAN_ONLY`.
68
+ * - `zlib.constants.Z_FIXED` Use to prevent the use of dynamic Huffman codes, allowing for a simpler decoder for special applications.
69
+ * - `zlib.constants.Z_HUFFMAN_ONLY` Use to force Huffman encoding only (no string match).
70
+ * - `zlib.constants.Z_RLE` Use to limit match distances to one (run-length encoding). This is designed to be almost as
71
+ * fast as `zlib.constants.Z_HUFFMAN_ONLY`, but give better compression for PNG image data.
72
+ *
73
+ * **Note** in the list above, `zlib` is from `zlib = require('zlib')`.
74
+ */
75
+ strategy?: number | undefined;
76
+ /**
77
+ * The byte threshold for the response body size before compression is considered for the response, defaults to
78
+ * 1kb. This is a number of bytes or any string accepted by the bytes module.
79
+ *
80
+ * **Note** this is only an advisory setting; if the response size cannot be determined at the time the response
81
+ * headers are written, then it is assumed the response is *over* the threshold. To guarantee the response size
82
+ * can be determined, be sure set a `Content-Length` response header.
83
+ *
84
+ * @see {@link https://www.npmjs.com/package/bytes|`bytes` module}
85
+ * @see {@link https://github.com/expressjs/compression#threshold|`threshold` documentation}
86
+ */
87
+ threshold?: number | string | undefined;
88
+ /**
89
+ * @default zlib.constants.Z_DEFAULT_WINDOWBITS or 15.
90
+ * @see {@link https://nodejs.org/api/zlib.html#zlib_memory_usage_tuning|Node.js documentation}
91
+ */
92
+ windowBits?: number | undefined;
93
+ /**
94
+ * In addition , `zlib` options may be passed in to the options object.
95
+ */
96
+ [property: string]: any;
97
+ }
98
+ export { CompressionOptions };
99
+ //# sourceMappingURL=compression.interface.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"compression.interface.d.ts","sourceRoot":"","sources":["../../../../../packages/core/src/middleware/interfaces/compression.interface.ts"],"names":[],"mappings":"AACA,OAAO,OAAO,MAAM,SAAS,CAAC;AAE9B,UAAU,iBAAiB;IACzB,CAAC,GAAG,EAAE,OAAO,CAAC,OAAO,EAAE,GAAG,EAAE,OAAO,CAAC,QAAQ,GAAG,OAAO,CAAC;CACxD;AAED,UAAU,kBAAkB;IAC1B;;;;OAIG;IACH,SAAS,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAE/B;;;;;;;;;;OAUG;IACH,MAAM,CAAC,EAAE,iBAAiB,GAAG,SAAS,CAAC;IAEvC;;;;;;;;;;;;;;;;;;;;;;;;OAwBG;IACH,KAAK,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAE3B;;;;;;;OAOG;IACH,QAAQ,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAE9B;;;;;;;;;;;;;;;OAeG;IACH,QAAQ,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAE9B;;;;;;;;;;OAUG;IACH,SAAS,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAAC;IAExC;;;OAGG;IACH,UAAU,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAChC;;OAEG;IACH,CAAC,QAAQ,EAAE,MAAM,GAAG,GAAG,CAAC;CACzB;AAED,OAAO,EAAE,kBAAkB,EAAE,CAAC"}
@@ -0,0 +1,58 @@
1
+ /**
2
+ * Represents the possible values for the `origin` property in the `CorsOptions` interface.
3
+ */
4
+ type StaticOrigin = boolean | string | RegExp | (boolean | string | RegExp)[];
5
+ /**
6
+ * A function type to define a custom origin configuration in the `CorsOptions` interface.
7
+ *
8
+ * @param requestOrigin - The origin of the incoming request, or undefined if not available.
9
+ * @param callback - A callback function to indicate whether the request origin is allowed or not.
10
+ */
11
+ type CustomOrigin = (requestOrigin: string | undefined, callback: (err: Error | null, origin?: StaticOrigin) => void) => void;
12
+ /**
13
+ * Interface to define Cross-Origin Resource Sharing (CORS) options.
14
+ */
15
+ interface CorsOptions {
16
+ /**
17
+ * Configures the Access-Control-Allow-Origin CORS header.
18
+ *
19
+ * @default '*' (allows requests from any origin)
20
+ */
21
+ origin?: StaticOrigin | CustomOrigin | undefined;
22
+ /**
23
+ * Configures the Access-Control-Allow-Methods CORS header.
24
+ *
25
+ * @default 'GET,HEAD,PUT,PATCH,POST,DELETE' (allows these HTTP methods)
26
+ */
27
+ methods?: string | Array<string> | undefined;
28
+ /**
29
+ * Configures the Access-Control-Allow-Headers CORS header.
30
+ */
31
+ allowedHeaders?: string | Array<string> | undefined;
32
+ /**
33
+ * Configures the Access-Control-Expose-Headers CORS header.
34
+ */
35
+ exposedHeaders?: string | Array<string> | undefined;
36
+ /**
37
+ * Configures the Access-Control-Allow-Credentials CORS header.
38
+ */
39
+ credentials?: boolean | undefined;
40
+ /**
41
+ * Configures the Access-Control-Max-Age CORS header.
42
+ */
43
+ maxAge?: number | undefined;
44
+ /**
45
+ * If true, allows preflight requests to pass to the next handler.
46
+ *
47
+ * @default false
48
+ */
49
+ preflightContinue?: boolean | undefined;
50
+ /**
51
+ * Defines the status code to be sent to the client on a successful OPTIONS request, as a part of the preflight request.
52
+ *
53
+ * @default 204
54
+ */
55
+ optionsSuccessStatus?: number | undefined;
56
+ }
57
+ export { CorsOptions };
58
+ //# sourceMappingURL=cors.interface.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cors.interface.d.ts","sourceRoot":"","sources":["../../../../../packages/core/src/middleware/interfaces/cors.interface.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,KAAK,YAAY,GAAG,OAAO,GAAG,MAAM,GAAG,MAAM,GAAG,CAAC,OAAO,GAAG,MAAM,GAAG,MAAM,CAAC,EAAE,CAAC;AAE9E;;;;;GAKG;AACH,KAAK,YAAY,GAAG,CAClB,aAAa,EAAE,MAAM,GAAG,SAAS,EACjC,QAAQ,EAAE,CAAC,GAAG,EAAE,KAAK,GAAG,IAAI,EAAE,MAAM,CAAC,EAAE,YAAY,KAAK,IAAI,KACzD,IAAI,CAAC;AAEV;;GAEG;AACH,UAAU,WAAW;IACnB;;;;OAIG;IACH,MAAM,CAAC,EAAE,YAAY,GAAG,YAAY,GAAG,SAAS,CAAC;IACjD;;;;OAIG;IACH,OAAO,CAAC,EAAE,MAAM,GAAG,KAAK,CAAC,MAAM,CAAC,GAAG,SAAS,CAAC;IAE7C;;OAEG;IACH,cAAc,CAAC,EAAE,MAAM,GAAG,KAAK,CAAC,MAAM,CAAC,GAAG,SAAS,CAAC;IAEpD;;OAEG;IACH,cAAc,CAAC,EAAE,MAAM,GAAG,KAAK,CAAC,MAAM,CAAC,GAAG,SAAS,CAAC;IAEpD;;OAEG;IACH,WAAW,CAAC,EAAE,OAAO,GAAG,SAAS,CAAC;IAElC;;OAEG;IACH,MAAM,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAE5B;;;;OAIG;IACH,iBAAiB,CAAC,EAAE,OAAO,GAAG,SAAS,CAAC;IAExC;;;;OAIG;IACH,oBAAoB,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;CAC3C;AAED,OAAO,EAAE,WAAW,EAAE,CAAC"}
@@ -0,0 +1,71 @@
1
+ /// <reference types="node" />
2
+ import http from "http";
3
+ interface ServeStaticOptions<R extends http.ServerResponse = http.ServerResponse> {
4
+ /**
5
+ * Enable or disable accepting ranged requests, defaults to true.
6
+ * Disabling this will not send Accept-Ranges and ignore the contents of the Range request header.
7
+ */
8
+ acceptRanges?: boolean | undefined;
9
+ /**
10
+ * Enable or disable setting Cache-Control response header, defaults to true.
11
+ * Disabling this will ignore the immutable and maxAge options.
12
+ */
13
+ cacheControl?: boolean | undefined;
14
+ /**
15
+ * Set how "dotfiles" are treated when encountered. A dotfile is a file or directory that begins with a dot (".").
16
+ * Note this check is done on the path itself without checking if the path actually exists on the disk.
17
+ * If root is specified, only the dotfiles above the root are checked (i.e. the root itself can be within a dotfile when when set to "deny").
18
+ * The default value is 'ignore'.
19
+ * 'allow' No special treatment for dotfiles
20
+ * 'deny' Send a 403 for any request for a dotfile
21
+ * 'ignore' Pretend like the dotfile does not exist and call next()
22
+ */
23
+ dotfiles?: string | undefined;
24
+ /**
25
+ * Enable or disable etag generation, defaults to true.
26
+ */
27
+ etag?: boolean | undefined;
28
+ /**
29
+ * Set file extension fallbacks. When set, if a file is not found, the given extensions will be added to the file name and search for.
30
+ * The first that exists will be served. Example: ['html', 'htm'].
31
+ * The default value is false.
32
+ */
33
+ extensions?: Array<string> | false | undefined;
34
+ /**
35
+ * Let client errors fall-through as unhandled requests, otherwise forward a client error.
36
+ * The default value is true.
37
+ */
38
+ fallthrough?: boolean | undefined;
39
+ /**
40
+ * Enable or disable the immutable directive in the Cache-Control response header.
41
+ * If enabled, the maxAge option should also be specified to enable caching. The immutable directive will prevent supported clients from making conditional requests during the life of the maxAge option to check if the file has changed.
42
+ */
43
+ immutable?: boolean | undefined;
44
+ /**
45
+ * By default this module will send "index.html" files in response to a request on a directory.
46
+ * To disable this set false or to supply a new index pass a string or an array in preferred order.
47
+ */
48
+ index?: boolean | string | Array<string> | undefined;
49
+ /**
50
+ * Enable or disable Last-Modified header, defaults to true. Uses the file system's last modified value.
51
+ */
52
+ lastModified?: boolean | undefined;
53
+ /**
54
+ * Provide a max-age in milliseconds for http caching, defaults to 0. This can also be a string accepted by the ms module.
55
+ */
56
+ maxAge?: number | string | undefined;
57
+ /**
58
+ * Redirect to trailing "/" when the pathname is a dir. Defaults to true.
59
+ */
60
+ redirect?: boolean | undefined;
61
+ /**
62
+ * Function to set custom headers on response. Alterations to the headers need to occur synchronously.
63
+ * The function is called as fn(res, path, stat), where the arguments are:
64
+ * res the response object
65
+ * path the file path that is being sent
66
+ * stat the stat object of the file that is being sent
67
+ */
68
+ setHeaders?: ((res: R, path: string, stat: any) => any) | undefined;
69
+ }
70
+ export { ServeStaticOptions };
71
+ //# sourceMappingURL=serve-static.interface.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"serve-static.interface.d.ts","sourceRoot":"","sources":["../../../../../packages/core/src/middleware/interfaces/serve-static.interface.ts"],"names":[],"mappings":";AAAA,OAAO,IAAI,MAAM,MAAM,CAAC;AAExB,UAAU,kBAAkB,CAC1B,CAAC,SAAS,IAAI,CAAC,cAAc,GAAG,IAAI,CAAC,cAAc;IAEnD;;;OAGG;IACH,YAAY,CAAC,EAAE,OAAO,GAAG,SAAS,CAAC;IAEnC;;;OAGG;IACH,YAAY,CAAC,EAAE,OAAO,GAAG,SAAS,CAAC;IAEnC;;;;;;;;OAQG;IACH,QAAQ,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAE9B;;OAEG;IACH,IAAI,CAAC,EAAE,OAAO,GAAG,SAAS,CAAC;IAE3B;;;;OAIG;IACH,UAAU,CAAC,EAAE,KAAK,CAAC,MAAM,CAAC,GAAG,KAAK,GAAG,SAAS,CAAC;IAE/C;;;OAGG;IACH,WAAW,CAAC,EAAE,OAAO,GAAG,SAAS,CAAC;IAElC;;;OAGG;IACH,SAAS,CAAC,EAAE,OAAO,GAAG,SAAS,CAAC;IAEhC;;;OAGG;IACH,KAAK,CAAC,EAAE,OAAO,GAAG,MAAM,GAAG,KAAK,CAAC,MAAM,CAAC,GAAG,SAAS,CAAC;IAErD;;OAEG;IACH,YAAY,CAAC,EAAE,OAAO,GAAG,SAAS,CAAC;IAEnC;;OAEG;IACH,MAAM,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAAC;IAErC;;OAEG;IACH,QAAQ,CAAC,EAAE,OAAO,GAAG,SAAS,CAAC;IAE/B;;;;;;OAMG;IAEH,UAAU,CAAC,EAAE,CAAC,CAAC,GAAG,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,GAAG,KAAK,GAAG,CAAC,GAAG,SAAS,CAAC;CACrE;AAED,OAAO,EAAE,kBAAkB,EAAE,CAAC"}
@@ -0,0 +1,12 @@
1
+ import express from "express";
2
+ /**
3
+ * A utility function that wraps the creation and retrieval of middleware.
4
+ * It creates a new instance of MiddlewareResolver and calls the getMiddleware method.
5
+ *
6
+ * @param {string} middleware - The name of the middleware to be retrieved.
7
+ * @param {...any} options - Optional arguments to configure the middleware.
8
+ * @returns {express.RequestHandler | null} - Returns the configured middleware or null if not found or not installed.
9
+ */
10
+ declare function middlewareResolver(middleware: string, ...options: any): express.RequestHandler | null;
11
+ export { middlewareResolver };
12
+ //# sourceMappingURL=middleware-resolver.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"middleware-resolver.d.ts","sourceRoot":"","sources":["../../../../packages/core/src/middleware/middleware-resolver.ts"],"names":[],"mappings":"AACA,OAAO,OAAO,MAAM,SAAS,CAAC;AAqE9B;;;;;;;GAOG;AACH,iBAAS,kBAAkB,CACzB,UAAU,EAAE,MAAM,EAClB,GAAG,OAAO,EAAE,GAAG,GACd,OAAO,CAAC,cAAc,GAAG,IAAI,CAG/B;AAED,OAAO,EAAE,kBAAkB,EAAE,CAAC"}
@@ -0,0 +1,137 @@
1
+ import express from "express";
2
+ import { OptionsJson } from "./interfaces/body-parser.interface";
3
+ import { CompressionOptions } from "./interfaces/compression.interface";
4
+ import { CorsOptions } from "./interfaces/cors.interface";
5
+ import { ServeStaticOptions } from "./interfaces/serve-static.interface";
6
+ type ExpressHandler = express.ErrorRequestHandler | express.RequestParamHandler | express.RequestHandler | undefined;
7
+ /**
8
+ * Interface for configuring and managing middlewares in the application.
9
+ * Provides methods to be added automatically in the application without the need to import packages.
10
+ */
11
+ interface IMiddleware {
12
+ /**
13
+ * Adds a Body Parser middleware to the middleware collection.
14
+ * The body parser is responsible for parsing the incoming request bodies in a middleware.
15
+ *
16
+ * @param options - Optional configuration options for the JSON body parser.
17
+ */
18
+ addBodyParser(options?: OptionsJson): void;
19
+ /**
20
+ * Adds Cross-Origin Resource Sharing (CORS) middleware to enable or control cross-origin requests.
21
+ *
22
+ * @param options - Optional configuration options for CORS. Defines the behavior of CORS requests like allowed origins, methods, headers, etc.
23
+ */
24
+ addCors(options?: CorsOptions): void;
25
+ /**
26
+ * Adds Compression middleware to reduce the size of the response body and improve the speed of the client-server communication.
27
+ *
28
+ * @param options - Optional configuration options for Compression. Allows fine-tuning the compression behavior, such as setting the compression level, threshold, and filter functions to determine which requests should be compressed.
29
+ */
30
+ addCompression(options?: CompressionOptions): void;
31
+ /**
32
+ * Configures the error handling middleware for the application.
33
+ *
34
+ * @param errorHandling - The Express error handler function that takes care of processing errors and formulating the response.
35
+ */
36
+ setErrorHandler(errorHandling?: ExpressHandler): void;
37
+ /**
38
+ * Adds a middleware to serve static files from the specified root directory.
39
+ * Allows the application to serve files like images, CSS, JavaScript, etc.
40
+ *
41
+ * @param root - The root directory from which the static assets are to be served.
42
+ * @param options - Optional configuration options for serving static files. Defines behavior like cache control, custom headers, etc.
43
+ */
44
+ serveStatic(root: string, options?: ServeStaticOptions): void;
45
+ /**
46
+ * Adds a middleware to the middleware collection.
47
+ *
48
+ * @param middleware - The Express request handler function to be added to the middleware collection.
49
+ *
50
+ */
51
+ addMiddleware(middleware: express.RequestHandler): void;
52
+ /**
53
+ * Retrieves all the middlewares that have been added.
54
+ *
55
+ * @returns An array of Express request handlers representing the middlewares.
56
+ */
57
+ getMiddlewares(): Array<express.RequestHandler>;
58
+ /**
59
+ * Gets the configured error handler middleware.
60
+ *
61
+ * @returns The error handler middleware.
62
+ */
63
+ getErrorHandler(): ExpressHandler;
64
+ }
65
+ /**
66
+ * Singleton class that implements the IConfigure interface.
67
+ * Manages the middleware configuration for the application,
68
+ * including adding Body Parser and retrieving all configured middlewares.
69
+ *
70
+ * @see IConfigure
71
+ */
72
+ declare class Middleware implements IMiddleware {
73
+ private middlewares;
74
+ private errorHandler;
75
+ private logger;
76
+ /**
77
+ * Checks if a middleware with the given name exists in the middleware collection.
78
+ *
79
+ * @param middlewareName - The name of the middleware to be checked.
80
+ *
81
+ * @returns A boolean value indicating whether the middleware exists or not.
82
+ */
83
+ private middlewareExists;
84
+ /**
85
+ * Adds a Body Parser middleware to the middleware collection using the given options.
86
+ *
87
+ * @param options - Optional configuration options for the JSON body parser.
88
+ */
89
+ addBodyParser(options?: OptionsJson): void;
90
+ /**
91
+ * Adds Cross-Origin Resource Sharing (CORS) middleware to enable or control cross-origin requests.
92
+ *
93
+ * @param options - Optional configuration options for CORS. Defines the behavior of CORS requests like allowed origins, methods, headers, etc.
94
+ */
95
+ addCors(options?: CorsOptions): void;
96
+ /**
97
+ * Adds Compression middleware to reduce the size of the response body and improve the speed of the client-server communication.
98
+ *
99
+ * @param options - Optional configuration options for Compression. Allows fine-tuning the compression behavior, such as setting the compression level, threshold, and filter functions to determine which requests should be compressed.
100
+ */
101
+ addCompression(options?: CompressionOptions): void;
102
+ /**
103
+ * Configures the error handling middleware for the application.
104
+ *
105
+ * @param errorHandling - The Express error handler function that takes care of processing errors and formulating the response.
106
+ */
107
+ setErrorHandler(errorHandling?: ExpressHandler): void;
108
+ /**
109
+ * Adds a middleware to serve static files from the specified root directory.
110
+ * Allows the application to serve files like images, CSS, JavaScript, etc.
111
+ *
112
+ * @param root - The root directory from which the static assets are to be served.
113
+ * @param options - Optional configuration options for serving static files. Defines behavior like cache control, custom headers, etc.
114
+ */
115
+ serveStatic(root: string, options?: ServeStaticOptions): void;
116
+ /**
117
+ * Adds a middleware to the middleware collection.
118
+ *
119
+ * @param middleware - The Express request handler function to be added to the middleware collection.
120
+ *
121
+ */
122
+ addMiddleware(middleware: express.RequestHandler): void;
123
+ /**
124
+ * Retrieves all the middlewares that have been added to the collection.
125
+ *
126
+ * @returns An array of Express request handlers representing the middlewares.
127
+ */
128
+ getMiddlewares(): Array<express.RequestHandler>;
129
+ /**
130
+ * Gets the configured error handler middleware.
131
+ *
132
+ * @returns The error handler middleware.
133
+ */
134
+ getErrorHandler(): ExpressHandler;
135
+ }
136
+ export { Middleware, IMiddleware };
137
+ //# sourceMappingURL=middleware-service.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"middleware-service.d.ts","sourceRoot":"","sources":["../../../../packages/core/src/middleware/middleware-service.ts"],"names":[],"mappings":"AAAA,OAAO,OAAO,MAAM,SAAS,CAAC;AAI9B,OAAO,EAAE,WAAW,EAAE,MAAM,oCAAoC,CAAC;AACjE,OAAO,EAAE,kBAAkB,EAAE,MAAM,oCAAoC,CAAC;AACxE,OAAO,EAAE,WAAW,EAAE,MAAM,6BAA6B,CAAC;AAC1D,OAAO,EAAE,kBAAkB,EAAE,MAAM,qCAAqC,CAAC;AAGzE,KAAK,cAAc,GACf,OAAO,CAAC,mBAAmB,GAC3B,OAAO,CAAC,mBAAmB,GAC3B,OAAO,CAAC,cAAc,GACtB,SAAS,CAAC;AAEd;;;GAGG;AACH,UAAU,WAAW;IACnB;;;;;OAKG;IACH,aAAa,CAAC,OAAO,CAAC,EAAE,WAAW,GAAG,IAAI,CAAC;IAE3C;;;;OAIG;IACH,OAAO,CAAC,OAAO,CAAC,EAAE,WAAW,GAAG,IAAI,CAAC;IAErC;;;;OAIG;IACH,cAAc,CAAC,OAAO,CAAC,EAAE,kBAAkB,GAAG,IAAI,CAAC;IAEnD;;;;OAIG;IACH,eAAe,CAAC,aAAa,CAAC,EAAE,cAAc,GAAG,IAAI,CAAC;IAEtD;;;;;;OAMG;IACH,WAAW,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,kBAAkB,GAAG,IAAI,CAAC;IAE9D;;;;;OAKG;IACH,aAAa,CAAC,UAAU,EAAE,OAAO,CAAC,cAAc,GAAG,IAAI,CAAC;IAExD;;;;OAIG;IACH,cAAc,IAAI,KAAK,CAAC,OAAO,CAAC,cAAc,CAAC,CAAC;IAEhD;;;;OAIG;IACH,eAAe,IAAI,cAAc,CAAC;CACnC;AAED;;;;;;GAMG;AACH,cACM,UAAW,YAAW,WAAW;IACrC,OAAO,CAAC,WAAW,CAAqC;IACxD,OAAO,CAAC,YAAY,CAA6B;IACjD,OAAO,CAAC,MAAM,CAAwB;IAEtC;;;;;;OAMG;IACH,OAAO,CAAC,gBAAgB;IASxB;;;;OAIG;IACI,aAAa,CAAC,OAAO,CAAC,EAAE,WAAW,GAAG,IAAI;IAajD;;;;OAIG;IACH,OAAO,CAAC,OAAO,CAAC,EAAE,WAAW,GAAG,IAAI;IASpC;;;;OAIG;IACH,cAAc,CAAC,OAAO,CAAC,EAAE,kBAAkB,GAAG,IAAI;IAUlD;;;;OAIG;IACH,eAAe,CAAC,aAAa,CAAC,EAAE,cAAc,GAAG,IAAI;IAQrD;;;;;;OAMG;IACH,WAAW,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,kBAAkB,GAAG,IAAI;IAa7D;;;;;OAKG;IACH,aAAa,CAAC,UAAU,EAAE,OAAO,CAAC,cAAc,GAAG,IAAI;IAavD;;;;OAIG;IACI,cAAc,IAAI,KAAK,CAAC,OAAO,CAAC,cAAc,CAAC;IAItD;;;;OAIG;IACI,eAAe,IAAI,cAAc;CAGzC;AAED,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,CAAC"}
@@ -0,0 +1,12 @@
1
+ import "reflect-metadata";
2
+ import { RequestHandler } from "express";
3
+ /**
4
+ * Validate the DTO using class-validator and class-transformer.
5
+ * @param type - The type of the DTO to validate.
6
+ * @returns A RequestHandler function.
7
+ * @throws An exception if the DTO is invalid.
8
+ *
9
+ */
10
+ declare function ValidateDTO<T extends object>(type: new () => T): RequestHandler;
11
+ export { ValidateDTO };
12
+ //# sourceMappingURL=dto-validator.provider.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"dto-validator.provider.d.ts","sourceRoot":"","sources":["../../../../../packages/core/src/provider/dto-validator/dto-validator.provider.ts"],"names":[],"mappings":"AAAA,OAAO,kBAAkB,CAAC;AAC1B,OAAO,EAAmC,cAAc,EAAE,MAAM,SAAS,CAAC;AAK1E;;;;;;GAMG;AACH,iBAAS,WAAW,CAAC,CAAC,SAAS,MAAM,EAAE,IAAI,EAAE,UAAU,CAAC,GAAG,cAAc,CA8CxE;AAED,OAAO,EAAE,WAAW,EAAE,CAAC"}
@@ -1,21 +1,24 @@
1
+ type DefaultValueType = string | number | boolean | undefined;
1
2
  /**
2
3
  * The EnvValidatorProvider class provides utility methods for working with environment variables.
3
4
  * It validates, loads, and retrieves environment variables from the .env file.
4
5
  * @provide EnvValidatorProvider
5
6
  */
6
7
  declare class EnvValidatorProvider {
8
+ private logger;
9
+ constructor();
7
10
  /**
8
11
  * Retrieves the value of an environment variable, or a default value if the variable is not set.
9
12
  * @param key - The key of the environment variable.
10
13
  * @param defaultValue - The default value to return if the environment variable is not set.
11
14
  * @returns The value of the environment variable, or the default value if not set.
12
15
  */
13
- static get(key: string, defaultValue?: any): any;
16
+ get(key: string, defaultValue?: DefaultValueType): DefaultValueType;
14
17
  /**
15
18
  * Validates and loads all environment variables from the .env file.
16
19
  * If the .env file does not exist or any environment variables are not set, the process will exit with an error.
17
20
  */
18
- static checkAll(): void;
21
+ checkAll(): void;
19
22
  }
20
23
  declare global {
21
24
  interface String {
@@ -24,5 +27,5 @@ declare global {
24
27
  AsString(): string | undefined;
25
28
  }
26
29
  }
27
- export { EnvValidatorProvider as Environments };
28
- //# sourceMappingURL=env-validator.d.ts.map
30
+ export { EnvValidatorProvider };
31
+ //# sourceMappingURL=env-validator.provider.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"env-validator.provider.d.ts","sourceRoot":"","sources":["../../../../../packages/core/src/provider/environment/env-validator.provider.ts"],"names":[],"mappings":"AAMA,KAAK,gBAAgB,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,SAAS,CAAC;AAE9D;;;;GAIG;AACH,cACM,oBAAoB;IACxB,OAAO,CAAC,MAAM,CAAS;;IAMvB;;;;;OAKG;IACI,GAAG,CACR,GAAG,EAAE,MAAM,EACX,YAAY,GAAE,gBAA4B,GACzC,gBAAgB;IAInB;;;OAGG;IACI,QAAQ,IAAI,IAAI;CAoCxB;AAED,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,MAAM;QACd,SAAS,IAAI,OAAO,GAAG,SAAS,CAAC;QACjC,QAAQ,IAAI,MAAM,GAAG,SAAS,CAAC;QAC/B,QAAQ,IAAI,MAAM,GAAG,SAAS,CAAC;KAChC;CACF;AAyBD,OAAO,EAAE,oBAAoB,EAAE,CAAC"}
@@ -0,0 +1,5 @@
1
+ export { Provider, IProvider } from "./provider-service";
2
+ export { Logger } from "./logger/logger-service";
3
+ export { EnvValidatorProvider as Env } from "./environment/env-validator.provider";
4
+ export { ValidateDTO } from "./dto-validator/dto-validator.provider";
5
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../packages/core/src/provider/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AACzD,OAAO,EAAE,MAAM,EAAE,MAAM,yBAAyB,CAAC;AACjD,OAAO,EAAE,oBAAoB,IAAI,GAAG,EAAE,MAAM,sCAAsC,CAAC;AACnF,OAAO,EAAE,WAAW,EAAE,MAAM,wCAAwC,CAAC"}
@@ -0,0 +1,50 @@
1
+ /**
2
+ * Represents the different logging levels.
3
+ */
4
+ type LogLevel = "INFO" | "WARN" | "ERROR" | "NONE";
5
+ /**
6
+ * Class that provides logging functionality with colorized text.
7
+ */
8
+ declare class Logger {
9
+ private pid;
10
+ constructor();
11
+ /**
12
+ * Formats the log message with color, timestamps, and log levels.
13
+ *
14
+ * @param logLevel - The level of the log (e.g. INFO, WARN).
15
+ * @param message - The main log message.
16
+ * @param module - Optional module name.
17
+ * @returns The formatted log message.
18
+ */
19
+ protected formatMessage(logLevel: LogLevel, message: string, module?: string): string;
20
+ /**
21
+ * Logs a generic message.
22
+ *
23
+ * @param message - The message to log.
24
+ * @param module - Optional module name.
25
+ */
26
+ msg(message: string, module?: string): void;
27
+ /**
28
+ * Logs an informational message.
29
+ *
30
+ * @param message - The message to log.
31
+ * @param module - Optional module name.
32
+ */
33
+ info(message: string, module?: string): void;
34
+ /**
35
+ * Logs a warning message.
36
+ *
37
+ * @param message - The message to log.
38
+ * @param module - Optional module name.
39
+ */
40
+ warn(message: string, module?: string): void;
41
+ /**
42
+ * Logs an error message.
43
+ *
44
+ * @param message - The message to log.
45
+ * @param module - Optional module name.
46
+ */
47
+ error(message: string, module?: string): void;
48
+ }
49
+ export { Logger, LogLevel };
50
+ //# sourceMappingURL=logger-service.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"logger-service.d.ts","sourceRoot":"","sources":["../../../../../packages/core/src/provider/logger/logger-service.ts"],"names":[],"mappings":"AAGA;;GAEG;AACH,KAAK,QAAQ,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,MAAM,CAAC;AAanD;;GAEG;AACH,cACM,MAAM;IACV,OAAO,CAAC,GAAG,CAAS;;IAMpB;;;;;;;OAOG;IACH,SAAS,CAAC,aAAa,CACrB,QAAQ,EAAE,QAAiB,EAC3B,OAAO,EAAE,MAAM,EACf,MAAM,CAAC,EAAE,MAAM,GACd,MAAM;IAqDT;;;;;OAKG;IACI,GAAG,CAAC,OAAO,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM,GAAG,IAAI;IAIlD;;;;;OAKG;IACI,IAAI,CAAC,OAAO,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM,GAAG,IAAI;IAInD;;;;;OAKG;IACI,IAAI,CAAC,OAAO,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM,GAAG,IAAI;IAInD;;;;;OAKG;IACI,KAAK,CAAC,OAAO,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM,GAAG,IAAI;CAGrD;AAED,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,CAAC"}
@@ -43,4 +43,4 @@ declare class GeneralLogger {
43
43
  }
44
44
  declare const log: (logLevel: LogLevel, content: Error | string, service?: string) => void;
45
45
  export { LogLevel, GeneralLogger, log };
46
- //# sourceMappingURL=general-logger.d.ts.map
46
+ //# sourceMappingURL=winston-logger.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"winston-logger.d.ts","sourceRoot":"","sources":["../../../../../packages/core/src/provider/logger/winston-logger.ts"],"names":[],"mappings":"AAUA;;GAEG;AACH,aAAK,QAAQ;IACX,KAAK,IAAA;IACL,KAAK,IAAA;IACL,IAAI,IAAA;CACL;AAED;;GAEG;AACH,cACM,aAAa;IACjB,OAAO,CAAC,MAAM,CAAS;;IAMvB;;;OAGG;IACH,OAAO,CAAC,sBAAsB;IAY9B;;;OAGG;IACH,OAAO,CAAC,6BAA6B;IAcrC;;;OAGG;IACH,OAAO,CAAC,mBAAmB;IAoB3B;;;;OAIG;IACH,OAAO,CAAC,cAAc;IAYtB;;;;;OAKG;IACI,GAAG,CACR,QAAQ,EAAE,QAAQ,EAClB,OAAO,EAAE,KAAK,GAAG,MAAM,EACvB,OAAO,CAAC,EAAE,MAAM,GACf,IAAI;CAyBR;AAGD,QAAA,MAAM,GAAG,aA/BK,QAAQ,WACT,KAAK,GAAG,MAAM,YACb,MAAM,KACf,IA4BwB,CAAC;AAE9B,OAAO,EAAE,QAAQ,EAAE,aAAa,EAAE,GAAG,EAAE,CAAC"}