@expressots/core 1.7.0 → 1.8.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 (66) hide show
  1. package/README.md +87 -41
  2. package/lib/CHANGELOG.md +16 -0
  3. package/lib/README.md +87 -41
  4. package/lib/cjs/application/app-container.js +3 -3
  5. package/lib/cjs/application/application.js +15 -2
  6. package/lib/cjs/console/console.js +3 -1
  7. package/lib/cjs/container-module/container-module.js +2 -0
  8. package/lib/cjs/decorator/scope-binding.js +2 -0
  9. package/lib/cjs/environment/env-validator.js +1 -0
  10. package/lib/cjs/error/error-handler-middleware.js +1 -1
  11. package/lib/cjs/logger/general-logger.js +2 -2
  12. package/lib/cjs/types/application/app-container.d.ts +71 -5
  13. package/lib/cjs/types/application/app-container.d.ts.map +1 -1
  14. package/lib/cjs/types/application/application.d.ts +5 -1
  15. package/lib/cjs/types/application/application.d.ts.map +1 -1
  16. package/lib/cjs/types/common/project-config.provider.d.ts.map +1 -1
  17. package/lib/cjs/types/console/console.d.ts.map +1 -1
  18. package/lib/cjs/types/container-module/container-module.d.ts +1 -1
  19. package/lib/cjs/types/container-module/container-module.d.ts.map +1 -1
  20. package/lib/cjs/types/controller/base-controller.d.ts.map +1 -1
  21. package/lib/cjs/types/decorator/scope-binding.d.ts.map +1 -1
  22. package/lib/cjs/types/environment/env-validator.d.ts.map +1 -1
  23. package/lib/cjs/types/error/error-handler-middleware.d.ts +2 -2
  24. package/lib/cjs/types/error/error-handler-middleware.d.ts.map +1 -1
  25. package/lib/cjs/types/logger/general-logger.d.ts.map +1 -1
  26. package/lib/esm/application/app-container.js +14 -11
  27. package/lib/esm/application/application.js +38 -18
  28. package/lib/esm/application/index.js +9 -2
  29. package/lib/esm/common/index.js +2 -1
  30. package/lib/esm/common/project-config.provider.js +2 -1
  31. package/lib/esm/console/console.js +18 -10
  32. package/lib/esm/console/index.js +5 -1
  33. package/lib/esm/container-module/container-module.js +23 -17
  34. package/lib/esm/container-module/index.js +6 -1
  35. package/lib/esm/controller/base-controller.js +9 -6
  36. package/lib/esm/controller/index.js +5 -1
  37. package/lib/esm/decorator/index.js +17 -1
  38. package/lib/esm/decorator/scope-binding.js +10 -4
  39. package/lib/esm/environment/env-validator.js +20 -13
  40. package/lib/esm/environment/index.js +5 -1
  41. package/lib/esm/error/error-handler-middleware.js +6 -4
  42. package/lib/esm/error/index.js +7 -2
  43. package/lib/esm/error/report.js +9 -6
  44. package/lib/esm/error/status-code.js +4 -1
  45. package/lib/esm/index.mjs +26 -10
  46. package/lib/esm/logger/general-logger.js +20 -13
  47. package/lib/esm/logger/index.js +7 -1
  48. package/lib/esm/render/handlebars.interface.js +2 -1
  49. package/lib/esm/render/index.js +2 -1
  50. package/lib/esm/render/render.type.js +2 -1
  51. package/lib/esm/types/application/app-container.d.ts +71 -5
  52. package/lib/esm/types/application/app-container.d.ts.map +1 -1
  53. package/lib/esm/types/application/application.d.ts +5 -1
  54. package/lib/esm/types/application/application.d.ts.map +1 -1
  55. package/lib/esm/types/common/project-config.provider.d.ts.map +1 -1
  56. package/lib/esm/types/console/console.d.ts.map +1 -1
  57. package/lib/esm/types/container-module/container-module.d.ts +1 -1
  58. package/lib/esm/types/container-module/container-module.d.ts.map +1 -1
  59. package/lib/esm/types/controller/base-controller.d.ts.map +1 -1
  60. package/lib/esm/types/decorator/scope-binding.d.ts.map +1 -1
  61. package/lib/esm/types/environment/env-validator.d.ts.map +1 -1
  62. package/lib/esm/types/error/error-handler-middleware.d.ts +2 -2
  63. package/lib/esm/types/error/error-handler-middleware.d.ts.map +1 -1
  64. package/lib/esm/types/logger/general-logger.d.ts.map +1 -1
  65. package/lib/package.json +15 -9
  66. package/package.json +15 -9
@@ -1,4 +1,4 @@
1
- import { NextFunction, Request, Response } from "express";
1
+ import { Request, Response } from "express";
2
2
  import { IAppError } from "./report";
3
3
  /**
4
4
  * errorHandler is a custom Express error-handling middleware function.
@@ -8,6 +8,6 @@ import { IAppError } from "./report";
8
8
  * @param res - The Express response object.
9
9
  * @param next - The Express next function for passing control to the next middleware function.
10
10
  */
11
- declare function errorHandler(error: IAppError, req: Request, res: Response, next: NextFunction): void;
11
+ declare function errorHandler(error: IAppError, req: Request, res: Response): void;
12
12
  export default errorHandler;
13
13
  //# sourceMappingURL=error-handler-middleware.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"error-handler-middleware.d.ts","sourceRoot":"","sources":["../../../../packages/core/src/error/error-handler-middleware.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAC1D,OAAO,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AAGrC;;;;;;;GAOG;AACH,iBAAS,YAAY,CACnB,KAAK,EAAE,SAAS,EAChB,GAAG,EAAE,OAAO,EACZ,GAAG,EAAE,QAAQ,EACb,IAAI,EAAE,YAAY,GACjB,IAAI,CAIN;AAED,eAAe,YAAY,CAAC"}
1
+ {"version":3,"file":"error-handler-middleware.d.ts","sourceRoot":"","sources":["../../../../packages/core/src/error/error-handler-middleware.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAC5C,OAAO,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AAGrC;;;;;;;GAOG;AACH,iBAAS,YAAY,CAAC,KAAK,EAAE,SAAS,EAAE,GAAG,EAAE,OAAO,EAAE,GAAG,EAAE,QAAQ,GAAG,IAAI,CAIzE;AAED,eAAe,YAAY,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"general-logger.d.ts","sourceRoot":"","sources":["../../../../packages/core/src/logger/general-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,CAAC,QAAQ,EAAE,QAAQ,EAAE,OAAO,EAAE,KAAK,GAAG,MAAM,EAAE,OAAO,CAAC,EAAE,MAAM;CAyBzE;AAGD,QAAA,MAAM,GAAG,aA5Bc,QAAQ,WAAW,KAAK,GAAG,MAAM,YAAY,MAAM,SA4B7C,CAAC;AAE9B,OAAO,EAAE,QAAQ,EAAE,aAAa,EAAE,GAAG,EAAE,CAAC"}
1
+ {"version":3,"file":"general-logger.d.ts","sourceRoot":"","sources":["../../../../packages/core/src/logger/general-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"}
@@ -1,3 +1,4 @@
1
+ "use strict";
1
2
  var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
2
3
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3
4
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
@@ -8,8 +9,10 @@ var __metadata = (this && this.__metadata) || function (k, v) {
8
9
  if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
9
10
  };
10
11
  var AppContainer_1;
11
- import { BindingScopeEnum, Container, } from "inversify";
12
- import { buildProviderModule, provide } from "inversify-binding-decorators";
12
+ Object.defineProperty(exports, "__esModule", { value: true });
13
+ exports.AppContainer = void 0;
14
+ const inversify_1 = require("inversify");
15
+ const inversify_binding_decorators_1 = require("inversify-binding-decorators");
13
16
  /**
14
17
  * The AppContainer class provides a container for managing dependency injection.
15
18
  * It allows the creation of a container with custom options, including default binding scope
@@ -26,12 +29,12 @@ let AppContainer = AppContainer_1 = class AppContainer {
26
29
  container;
27
30
  options;
28
31
  /**
29
- * Constructs the AppContainer instance.
30
- * @param options - The options for creating the container. Can include custom default scope and skip base class checks setting.
31
- */
32
+ * Constructs the AppContainer instance.
33
+ * @param options - The options for creating the container. Can include custom default scope and skip base class checks setting.
34
+ */
32
35
  constructor(options) {
33
36
  this.options = {
34
- defaultScope: BindingScopeEnum.Request,
37
+ defaultScope: inversify_1.BindingScopeEnum.Request,
35
38
  ...options,
36
39
  };
37
40
  }
@@ -46,8 +49,8 @@ let AppContainer = AppContainer_1 = class AppContainer {
46
49
  autoBindInjectable: true,
47
50
  ...this.options,
48
51
  };
49
- this.container = new Container(containerOptions);
50
- this.container.load(buildProviderModule(), ...modules);
52
+ this.container = new inversify_1.Container(containerOptions);
53
+ this.container.load((0, inversify_binding_decorators_1.buildProviderModule)(), ...modules);
51
54
  return this.container;
52
55
  }
53
56
  /**
@@ -72,8 +75,8 @@ let AppContainer = AppContainer_1 = class AppContainer {
72
75
  return this.container;
73
76
  }
74
77
  };
75
- AppContainer = AppContainer_1 = __decorate([
76
- provide(AppContainer_1),
78
+ exports.AppContainer = AppContainer;
79
+ exports.AppContainer = AppContainer = AppContainer_1 = __decorate([
80
+ (0, inversify_binding_decorators_1.provide)(AppContainer_1),
77
81
  __metadata("design:paramtypes", [Object])
78
82
  ], AppContainer);
79
- export { AppContainer };
@@ -1,3 +1,4 @@
1
+ "use strict";
1
2
  var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
2
3
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3
4
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
@@ -7,13 +8,18 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
7
8
  var __metadata = (this && this.__metadata) || function (k, v) {
8
9
  if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
9
10
  };
11
+ var __importDefault = (this && this.__importDefault) || function (mod) {
12
+ return (mod && mod.__esModule) ? mod : { "default": mod };
13
+ };
10
14
  var Application_1;
11
- import process from "process";
12
- import express from "express";
13
- import { provide } from "inversify-binding-decorators";
14
- import { InversifyExpressServer } from "inversify-express-utils";
15
- import { Console } from "../console/console";
16
- import errorHandler from "../error/error-handler-middleware";
15
+ Object.defineProperty(exports, "__esModule", { value: true });
16
+ exports.ServerEnvironment = exports.Application = exports.AppInstance = void 0;
17
+ const process_1 = __importDefault(require("process"));
18
+ const express_1 = __importDefault(require("express"));
19
+ const inversify_binding_decorators_1 = require("inversify-binding-decorators");
20
+ const inversify_express_utils_1 = require("inversify-express-utils");
21
+ const console_1 = require("../console/console");
22
+ const error_handler_middleware_1 = __importDefault(require("../error/error-handler-middleware"));
17
23
  /**
18
24
  * Enum representing possible server environments.
19
25
  */
@@ -22,7 +28,7 @@ var ServerEnvironment;
22
28
  ServerEnvironment["Development"] = "development";
23
29
  ServerEnvironment["Staging"] = "staging";
24
30
  ServerEnvironment["Production"] = "production";
25
- })(ServerEnvironment || (ServerEnvironment = {}));
31
+ })(ServerEnvironment || (exports.ServerEnvironment = ServerEnvironment = {}));
26
32
  /**
27
33
  * The Application class provides a way to configure and manage an Express application.
28
34
  * @provide Application
@@ -46,8 +52,13 @@ let Application = Application_1 = class Application {
46
52
  /**
47
53
  * Perform actions or cleanup after the server is shutdown.
48
54
  */
49
- serverShutdown() {
50
- process.exit(0);
55
+ serverShutdown() { }
56
+ /**
57
+ * Handles process exit by calling serverShutdown and then exiting the process.
58
+ */
59
+ handleExit() {
60
+ this.serverShutdown();
61
+ process_1.default.exit(0);
51
62
  }
52
63
  /**
53
64
  * Create and configure the Express application.
@@ -57,7 +68,7 @@ let Application = Application_1 = class Application {
57
68
  */
58
69
  create(container, middlewares = []) {
59
70
  this.configureServices();
60
- const expressServer = new InversifyExpressServer(container);
71
+ const expressServer = new inversify_express_utils_1.InversifyExpressServer(container);
61
72
  expressServer.setConfig((app) => {
62
73
  // Detect if a middleware in the array has a body parser. If so, replace the default body parser.
63
74
  const hasCustomBodyParser = middlewares.some((middleware) => {
@@ -67,9 +78,9 @@ let Application = Application_1 = class Application {
67
78
  });
68
79
  if (!hasCustomBodyParser) {
69
80
  /* Default body parser application/json */
70
- app.use(express.json());
81
+ app.use(express_1.default.json());
71
82
  /* Default body parser application/x-www-form-urlencoded */
72
- app.use(express.urlencoded({ extended: true }));
83
+ app.use(express_1.default.urlencoded({ extended: true }));
73
84
  }
74
85
  middlewares.forEach((middleware) => {
75
86
  app.use(middleware);
@@ -77,7 +88,7 @@ let Application = Application_1 = class Application {
77
88
  });
78
89
  this.app = expressServer.build();
79
90
  /* Add the error handler middleware */
80
- this.app.use(errorHandler);
91
+ this.app.use(error_handler_middleware_1.default);
81
92
  return this;
82
93
  }
83
94
  /**
@@ -90,8 +101,16 @@ let Application = Application_1 = class Application {
90
101
  this.port = port;
91
102
  this.environment = environment;
92
103
  this.app.listen(this.port, () => {
93
- new Console().messageServer(this.port, this.environment, consoleMessage);
94
- process.on("SIGINT", this.serverShutdown.bind(this));
104
+ new console_1.Console().messageServer(this.port, this.environment, consoleMessage);
105
+ [
106
+ "SIGTERM",
107
+ "SIGHUP",
108
+ "SIGBREAK",
109
+ "SIGQUIT",
110
+ "SIGINT",
111
+ ].forEach((signal) => {
112
+ process_1.default.on(signal, this.handleExit.bind(this));
113
+ });
95
114
  });
96
115
  this.postServerInitialization();
97
116
  }
@@ -115,9 +134,10 @@ let Application = Application_1 = class Application {
115
134
  }
116
135
  }
117
136
  };
118
- Application = Application_1 = __decorate([
119
- provide(Application_1),
137
+ exports.Application = Application;
138
+ exports.Application = Application = Application_1 = __decorate([
139
+ (0, inversify_binding_decorators_1.provide)(Application_1),
120
140
  __metadata("design:paramtypes", [])
121
141
  ], Application);
122
142
  const appServerInstance = new Application();
123
- export { appServerInstance as AppInstance, Application, ServerEnvironment };
143
+ exports.AppInstance = appServerInstance;
@@ -1,2 +1,9 @@
1
- export { AppInstance, Application, ServerEnvironment } from "./application";
2
- export { AppContainer } from "./app-container";
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.AppContainer = exports.ServerEnvironment = exports.Application = exports.AppInstance = void 0;
4
+ var application_1 = require("./application");
5
+ Object.defineProperty(exports, "AppInstance", { enumerable: true, get: function () { return application_1.AppInstance; } });
6
+ Object.defineProperty(exports, "Application", { enumerable: true, get: function () { return application_1.Application; } });
7
+ Object.defineProperty(exports, "ServerEnvironment", { enumerable: true, get: function () { return application_1.ServerEnvironment; } });
8
+ var app_container_1 = require("./app-container");
9
+ Object.defineProperty(exports, "AppContainer", { enumerable: true, get: function () { return app_container_1.AppContainer; } });
@@ -1 +1,2 @@
1
- export {};
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -1 +1,2 @@
1
- export {};
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,12 +1,18 @@
1
+ "use strict";
1
2
  var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
2
3
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3
4
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
4
5
  else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
5
6
  return c > 3 && r && Object.defineProperty(target, key, r), r;
6
7
  };
8
+ var __importDefault = (this && this.__importDefault) || function (mod) {
9
+ return (mod && mod.__esModule) ? mod : { "default": mod };
10
+ };
7
11
  var Console_1;
8
- import chalk from "chalk";
9
- import { provide } from "inversify-binding-decorators";
12
+ Object.defineProperty(exports, "__esModule", { value: true });
13
+ exports.Console = void 0;
14
+ const chalk_1 = __importDefault(require("chalk"));
15
+ const inversify_binding_decorators_1 = require("inversify-binding-decorators");
10
16
  /**
11
17
  * Enum representing possible color styles for console output.
12
18
  */
@@ -31,13 +37,13 @@ let Console = Console_1 = class Console {
31
37
  async printColor(message, colorStyle) {
32
38
  switch (colorStyle) {
33
39
  case ColorStyle.Yellow:
34
- return console.log(chalk.bgYellow.black(message));
40
+ return console.log(chalk_1.default.bgYellow.black(message));
35
41
  case ColorStyle.Blue:
36
- return console.log(chalk.bgBlue.black(message));
42
+ return console.log(chalk_1.default.bgBlue.black(message));
37
43
  case ColorStyle.Green:
38
- return console.log(chalk.bgGreen.black(message));
44
+ return console.log(chalk_1.default.bgGreen.black(message));
39
45
  case ColorStyle.Red:
40
- return console.log(chalk.bgRed.black(message));
46
+ return console.log(chalk_1.default.bgRed.black(message));
41
47
  }
42
48
  }
43
49
  /**
@@ -46,7 +52,9 @@ let Console = Console_1 = class Console {
46
52
  * @param environment - The server environment.
47
53
  * @param consoleMessage - Optional application message details for console output.
48
54
  */
49
- async messageServer(port, environment, consoleMessage) {
55
+ async messageServer(
56
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
57
+ port, environment, consoleMessage) {
50
58
  const appConsoleMessage = {
51
59
  appName: consoleMessage?.appName || "Application",
52
60
  appVersion: consoleMessage?.appVersion || "not provided",
@@ -70,7 +78,7 @@ let Console = Console_1 = class Console {
70
78
  `port ${port} - Environment: ${environment}`, terminalColor);
71
79
  }
72
80
  };
73
- Console = Console_1 = __decorate([
74
- provide(Console_1)
81
+ exports.Console = Console;
82
+ exports.Console = Console = Console_1 = __decorate([
83
+ (0, inversify_binding_decorators_1.provide)(Console_1)
75
84
  ], Console);
76
- export { Console };
@@ -1 +1,5 @@
1
- export { Console } from "./console";
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Console = void 0;
4
+ var console_1 = require("./console");
5
+ Object.defineProperty(exports, "Console", { enumerable: true, get: function () { return console_1.Console; } });
@@ -1,3 +1,4 @@
1
+ "use strict";
1
2
  var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
2
3
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3
4
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
@@ -5,9 +6,13 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
5
6
  return c > 3 && r && Object.defineProperty(target, key, r), r;
6
7
  };
7
8
  var BaseModule_1;
8
- import { BindingScopeEnum, ContainerModule } from "inversify";
9
- import { provide } from "inversify-binding-decorators";
10
- import { provideSingleton, provideTransient } from "../decorator";
9
+ Object.defineProperty(exports, "__esModule", { value: true });
10
+ exports.scope = exports.CreateModule = void 0;
11
+ /* eslint-disable @typescript-eslint/explicit-function-return-type */
12
+ /* eslint-disable @typescript-eslint/no-explicit-any */
13
+ const inversify_1 = require("inversify");
14
+ const inversify_binding_decorators_1 = require("inversify-binding-decorators");
15
+ const decorator_1 = require("../decorator");
11
16
  /**
12
17
  * Key to be used for storing and retrieving binding type metadata.
13
18
  */
@@ -22,19 +27,20 @@ const scope = (binding) => {
22
27
  if (!Reflect.hasMetadata(BINDING_TYPE_METADATA_KEY, target)) {
23
28
  Reflect.defineMetadata(BINDING_TYPE_METADATA_KEY, binding, target);
24
29
  switch (binding) {
25
- case BindingScopeEnum.Singleton:
26
- provideSingleton(target);
30
+ case inversify_1.BindingScopeEnum.Singleton:
31
+ (0, decorator_1.provideSingleton)(target);
27
32
  break;
28
- case BindingScopeEnum.Transient:
29
- provideTransient(target);
33
+ case inversify_1.BindingScopeEnum.Transient:
34
+ (0, decorator_1.provideTransient)(target);
30
35
  break;
31
36
  default:
32
- provide(target);
37
+ (0, inversify_binding_decorators_1.provide)(target);
33
38
  break;
34
39
  }
35
40
  }
36
41
  };
37
42
  };
43
+ exports.scope = scope;
38
44
  /**
39
45
  * The BaseModule class provides methods for creating InversifyJS container modules.
40
46
  * @provide BaseModule
@@ -62,17 +68,17 @@ let BaseModule = BaseModule_1 = class BaseModule {
62
68
  */
63
69
  static createContainerModule(controllers, scope) {
64
70
  const symbols = BaseModule_1.createSymbols(controllers);
65
- return new ContainerModule((bind) => {
71
+ return new inversify_1.ContainerModule((bind) => {
66
72
  for (const [symbol, target] of symbols) {
67
73
  if (scope) {
68
74
  switch (scope) {
69
- case BindingScopeEnum.Singleton:
75
+ case inversify_1.BindingScopeEnum.Singleton:
70
76
  bind(symbol).to(target).inSingletonScope();
71
77
  break;
72
- case BindingScopeEnum.Transient:
78
+ case inversify_1.BindingScopeEnum.Transient:
73
79
  bind(symbol).to(target).inTransientScope();
74
80
  break;
75
- case BindingScopeEnum.Request:
81
+ case inversify_1.BindingScopeEnum.Request:
76
82
  bind(symbol).to(target).inRequestScope();
77
83
  break;
78
84
  }
@@ -80,13 +86,13 @@ let BaseModule = BaseModule_1 = class BaseModule {
80
86
  else {
81
87
  const bindingType = Reflect.getMetadata(BINDING_TYPE_METADATA_KEY, target);
82
88
  switch (bindingType) {
83
- case BindingScopeEnum.Singleton:
89
+ case inversify_1.BindingScopeEnum.Singleton:
84
90
  bind(symbol).to(target).inSingletonScope();
85
91
  break;
86
- case BindingScopeEnum.Transient:
92
+ case inversify_1.BindingScopeEnum.Transient:
87
93
  bind(symbol).to(target).inTransientScope();
88
94
  break;
89
- case BindingScopeEnum.Request:
95
+ case inversify_1.BindingScopeEnum.Request:
90
96
  bind(symbol).to(target).inRequestScope();
91
97
  break;
92
98
  default:
@@ -99,7 +105,7 @@ let BaseModule = BaseModule_1 = class BaseModule {
99
105
  }
100
106
  };
101
107
  BaseModule = BaseModule_1 = __decorate([
102
- provide(BaseModule_1)
108
+ (0, inversify_binding_decorators_1.provide)(BaseModule_1)
103
109
  ], BaseModule);
104
110
  const CreateModule = BaseModule.createContainerModule;
105
- export { CreateModule, scope };
111
+ exports.CreateModule = CreateModule;
@@ -1 +1,6 @@
1
- export { CreateModule, scope } from "./container-module";
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.scope = exports.CreateModule = void 0;
4
+ var container_module_1 = require("./container-module");
5
+ Object.defineProperty(exports, "CreateModule", { enumerable: true, get: function () { return container_module_1.CreateModule; } });
6
+ Object.defineProperty(exports, "scope", { enumerable: true, get: function () { return container_module_1.scope; } });
@@ -1,3 +1,4 @@
1
+ "use strict";
1
2
  var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
2
3
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3
4
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
@@ -8,8 +9,10 @@ var __metadata = (this && this.__metadata) || function (k, v) {
8
9
  if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
9
10
  };
10
11
  var BaseController_1;
11
- import { provide } from "inversify-binding-decorators";
12
- import { log, LogLevel } from "../logger";
12
+ Object.defineProperty(exports, "__esModule", { value: true });
13
+ exports.BaseController = void 0;
14
+ const inversify_binding_decorators_1 = require("inversify-binding-decorators");
15
+ const logger_1 = require("../logger");
13
16
  /**
14
17
  * The BaseController class is an abstract base class for controllers.
15
18
  * It provides methods for handling use case calls and sending appropriate responses.
@@ -71,7 +74,7 @@ let BaseController = BaseController_1 = class BaseController {
71
74
  return new Promise((resolve, reject) => {
72
75
  res.render(template, options, (err, compiled) => {
73
76
  if (err) {
74
- log(LogLevel.Error, err.message, "base-controller");
77
+ (0, logger_1.log)(logger_1.LogLevel.Error, err.message, "base-controller");
75
78
  reject(err);
76
79
  }
77
80
  resolve(compiled);
@@ -79,8 +82,8 @@ let BaseController = BaseController_1 = class BaseController {
79
82
  });
80
83
  }
81
84
  };
82
- BaseController = BaseController_1 = __decorate([
83
- provide(BaseController_1),
85
+ exports.BaseController = BaseController;
86
+ exports.BaseController = BaseController = BaseController_1 = __decorate([
87
+ (0, inversify_binding_decorators_1.provide)(BaseController_1),
84
88
  __metadata("design:paramtypes", [String])
85
89
  ], BaseController);
86
- export { BaseController };
@@ -1 +1,5 @@
1
- export { BaseController } from "./base-controller";
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.BaseController = void 0;
4
+ var base_controller_1 = require("./base-controller");
5
+ Object.defineProperty(exports, "BaseController", { enumerable: true, get: function () { return base_controller_1.BaseController; } });
@@ -1 +1,17 @@
1
- export * from "./scope-binding";
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 __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./scope-binding"), exports);
@@ -1,8 +1,14 @@
1
- import { fluentProvide } from "inversify-binding-decorators";
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.provideTransient = exports.provideSingleton = void 0;
4
+ /* eslint-disable @typescript-eslint/explicit-function-return-type */
5
+ /* eslint-disable @typescript-eslint/no-explicit-any */
6
+ const inversify_binding_decorators_1 = require("inversify-binding-decorators");
2
7
  const provideSingleton = (identifier) => {
3
- return fluentProvide(identifier).inSingletonScope().done();
8
+ return (0, inversify_binding_decorators_1.fluentProvide)(identifier).inSingletonScope().done();
4
9
  };
10
+ exports.provideSingleton = provideSingleton;
5
11
  const provideTransient = (identifier) => {
6
- return fluentProvide(identifier).inTransientScope().done();
12
+ return (0, inversify_binding_decorators_1.fluentProvide)(identifier).inTransientScope().done();
7
13
  };
8
- export { provideSingleton, provideTransient };
14
+ exports.provideTransient = provideTransient;
@@ -1,15 +1,21 @@
1
+ "use strict";
1
2
  var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
2
3
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3
4
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
4
5
  else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
5
6
  return c > 3 && r && Object.defineProperty(target, key, r), r;
6
7
  };
8
+ var __importDefault = (this && this.__importDefault) || function (mod) {
9
+ return (mod && mod.__esModule) ? mod : { "default": mod };
10
+ };
7
11
  var EnvValidatorProvider_1;
8
- import fs from "fs";
9
- import path from "path";
10
- import dotenv from "dotenv";
11
- import { provide } from "inversify-binding-decorators";
12
- import { log, LogLevel } from "../logger";
12
+ Object.defineProperty(exports, "__esModule", { value: true });
13
+ exports.Environments = void 0;
14
+ const fs_1 = __importDefault(require("fs"));
15
+ const path_1 = __importDefault(require("path"));
16
+ const dotenv_1 = __importDefault(require("dotenv"));
17
+ const inversify_binding_decorators_1 = require("inversify-binding-decorators");
18
+ const logger_1 = require("../logger");
13
19
  /**
14
20
  * The EnvValidatorProvider class provides utility methods for working with environment variables.
15
21
  * It validates, loads, and retrieves environment variables from the .env file.
@@ -22,6 +28,7 @@ let EnvValidatorProvider = EnvValidatorProvider_1 = class EnvValidatorProvider {
22
28
  * @param defaultValue - The default value to return if the environment variable is not set.
23
29
  * @returns The value of the environment variable, or the default value if not set.
24
30
  */
31
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
25
32
  static get(key, defaultValue = undefined) {
26
33
  return process.env[key] ?? defaultValue;
27
34
  }
@@ -31,14 +38,14 @@ let EnvValidatorProvider = EnvValidatorProvider_1 = class EnvValidatorProvider {
31
38
  */
32
39
  static checkAll() {
33
40
  // Get the full path of the .env file
34
- const envFilePath = path.join(process.cwd(), ".", ".env");
41
+ const envFilePath = path_1.default.join(process.cwd(), ".", ".env");
35
42
  // Check if the .env file exists
36
- if (!fs.existsSync(envFilePath)) {
37
- log(LogLevel.Info, "Environment file .env is not defined.", "env-validator-provider");
43
+ if (!fs_1.default.existsSync(envFilePath)) {
44
+ (0, logger_1.log)(logger_1.LogLevel.Info, "Environment file .env is not defined.", "env-validator-provider");
38
45
  process.exit(1);
39
46
  }
40
47
  // Load the environment variables from the .env file
41
- const dotenvConfigOutput = dotenv.config({ path: envFilePath });
48
+ const dotenvConfigOutput = dotenv_1.default.config({ path: envFilePath });
42
49
  const dotEnvParsed = dotenvConfigOutput.parsed;
43
50
  /* Verify if all environment variables are defined */
44
51
  let hasError = false;
@@ -46,7 +53,7 @@ let EnvValidatorProvider = EnvValidatorProvider_1 = class EnvValidatorProvider {
46
53
  for (const key of Object.keys(dotEnvParsed)) {
47
54
  // Check if the environment variable is not defined or is an empty string
48
55
  if (!process.env[key] || process.env[key] === "") {
49
- log(LogLevel.Info, `Environment variable ${key} is not defined.`, "env-validator-provider");
56
+ (0, logger_1.log)(logger_1.LogLevel.Info, `Environment variable ${key} is not defined.`, "env-validator-provider");
50
57
  hasError = true;
51
58
  }
52
59
  }
@@ -56,8 +63,9 @@ let EnvValidatorProvider = EnvValidatorProvider_1 = class EnvValidatorProvider {
56
63
  }
57
64
  }
58
65
  };
59
- EnvValidatorProvider = EnvValidatorProvider_1 = __decorate([
60
- provide(EnvValidatorProvider_1)
66
+ exports.Environments = EnvValidatorProvider;
67
+ exports.Environments = EnvValidatorProvider = EnvValidatorProvider_1 = __decorate([
68
+ (0, inversify_binding_decorators_1.provide)(EnvValidatorProvider_1)
61
69
  ], EnvValidatorProvider);
62
70
  String.prototype.AsBoolean = function () {
63
71
  switch (this.toLowerCase().trim()) {
@@ -79,4 +87,3 @@ String.prototype.AsNumber = function () {
79
87
  String.prototype.AsString = function () {
80
88
  return String(this);
81
89
  };
82
- export { EnvValidatorProvider as Environments };
@@ -1 +1,5 @@
1
- export { Environments } from "./env-validator";
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Environments = void 0;
4
+ var env_validator_1 = require("./env-validator");
5
+ Object.defineProperty(exports, "Environments", { enumerable: true, get: function () { return env_validator_1.Environments; } });
@@ -1,4 +1,6 @@
1
- import { StatusCode } from "./status-code";
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const status_code_1 = require("./status-code");
2
4
  /**
3
5
  * errorHandler is a custom Express error-handling middleware function.
4
6
  * It logs the error, sets the status code, and sends a JSON response containing the status code and error message.
@@ -7,9 +9,9 @@ import { StatusCode } from "./status-code";
7
9
  * @param res - The Express response object.
8
10
  * @param next - The Express next function for passing control to the next middleware function.
9
11
  */
10
- function errorHandler(error, req, res, next) {
12
+ function errorHandler(error, req, res) {
11
13
  res
12
- .status(error.statusCode || StatusCode.InternalServerError)
14
+ .status(error.statusCode || status_code_1.StatusCode.InternalServerError)
13
15
  .json({ statusCode: error.statusCode, error: error.message });
14
16
  }
15
- export default errorHandler;
17
+ exports.default = errorHandler;
@@ -1,2 +1,7 @@
1
- export { StatusCode } from "./status-code";
2
- export { Report } from "./report";
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Report = exports.StatusCode = void 0;
4
+ var status_code_1 = require("./status-code");
5
+ Object.defineProperty(exports, "StatusCode", { enumerable: true, get: function () { return status_code_1.StatusCode; } });
6
+ var report_1 = require("./report");
7
+ Object.defineProperty(exports, "Report", { enumerable: true, get: function () { return report_1.Report; } });