@expressots/adapter-express 0.0.1-dev.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 (84) hide show
  1. package/LICENSE.md +21 -0
  2. package/README.md +107 -0
  3. package/lib/CHANGELOG.md +8 -0
  4. package/lib/README.md +107 -0
  5. package/lib/cjs/adapter-express/application-express.interface.js +2 -0
  6. package/lib/cjs/adapter-express/application-express.js +147 -0
  7. package/lib/cjs/adapter-express/express-utils/base-middleware.js +19 -0
  8. package/lib/cjs/adapter-express/express-utils/constants.js +46 -0
  9. package/lib/cjs/adapter-express/express-utils/content/httpContent.js +12 -0
  10. package/lib/cjs/adapter-express/express-utils/decorators.js +110 -0
  11. package/lib/cjs/adapter-express/express-utils/httpResponseMessage.js +31 -0
  12. package/lib/cjs/adapter-express/express-utils/index.js +17 -0
  13. package/lib/cjs/adapter-express/express-utils/interfaces.js +2 -0
  14. package/lib/cjs/adapter-express/express-utils/inversify-express-server.js +300 -0
  15. package/lib/cjs/adapter-express/express-utils/utils.js +58 -0
  16. package/lib/cjs/adapter-express/index.js +21 -0
  17. package/lib/cjs/index.js +17 -0
  18. package/lib/cjs/types/adapter-express/application-express.d.ts +70 -0
  19. package/lib/cjs/types/adapter-express/application-express.d.ts.map +1 -0
  20. package/lib/cjs/types/adapter-express/application-express.interface.d.ts +29 -0
  21. package/lib/cjs/types/adapter-express/application-express.interface.d.ts.map +1 -0
  22. package/lib/cjs/types/adapter-express/express-utils/base-middleware.d.ts +9 -0
  23. package/lib/cjs/types/adapter-express/express-utils/base-middleware.d.ts.map +1 -0
  24. package/lib/cjs/types/adapter-express/express-utils/constants.d.ts +39 -0
  25. package/lib/cjs/types/adapter-express/express-utils/constants.d.ts.map +1 -0
  26. package/lib/cjs/types/adapter-express/express-utils/content/httpContent.d.ts +8 -0
  27. package/lib/cjs/types/adapter-express/express-utils/content/httpContent.d.ts.map +1 -0
  28. package/lib/cjs/types/adapter-express/express-utils/decorators.d.ts +24 -0
  29. package/lib/cjs/types/adapter-express/express-utils/decorators.d.ts.map +1 -0
  30. package/lib/cjs/types/adapter-express/express-utils/httpResponseMessage.d.ts +16 -0
  31. package/lib/cjs/types/adapter-express/express-utils/httpResponseMessage.d.ts.map +1 -0
  32. package/lib/cjs/types/adapter-express/express-utils/index.d.ts +2 -0
  33. package/lib/cjs/types/adapter-express/express-utils/index.d.ts.map +1 -0
  34. package/lib/cjs/types/adapter-express/express-utils/interfaces.d.ts +76 -0
  35. package/lib/cjs/types/adapter-express/express-utils/interfaces.d.ts.map +1 -0
  36. package/lib/cjs/types/adapter-express/express-utils/inversify-express-server.d.ts +60 -0
  37. package/lib/cjs/types/adapter-express/express-utils/inversify-express-server.d.ts.map +1 -0
  38. package/lib/cjs/types/adapter-express/express-utils/utils.d.ts +10 -0
  39. package/lib/cjs/types/adapter-express/express-utils/utils.d.ts.map +1 -0
  40. package/lib/cjs/types/adapter-express/index.d.ts +4 -0
  41. package/lib/cjs/types/adapter-express/index.d.ts.map +1 -0
  42. package/lib/cjs/types/index.d.ts +2 -0
  43. package/lib/cjs/types/index.d.ts.map +1 -0
  44. package/lib/esm/adapter-express/application-express.interface.js +2 -0
  45. package/lib/esm/adapter-express/application-express.js +135 -0
  46. package/lib/esm/adapter-express/express-utils/base-middleware.js +22 -0
  47. package/lib/esm/adapter-express/express-utils/constants.js +46 -0
  48. package/lib/esm/adapter-express/express-utils/content/httpContent.js +10 -0
  49. package/lib/esm/adapter-express/express-utils/decorators.js +110 -0
  50. package/lib/esm/adapter-express/express-utils/httpResponseMessage.js +33 -0
  51. package/lib/esm/adapter-express/express-utils/index.js +17 -0
  52. package/lib/esm/adapter-express/express-utils/interfaces.js +2 -0
  53. package/lib/esm/adapter-express/express-utils/inversify-express-server.js +293 -0
  54. package/lib/esm/adapter-express/express-utils/utils.js +58 -0
  55. package/lib/esm/adapter-express/index.js +21 -0
  56. package/lib/esm/index.mjs +17 -0
  57. package/lib/esm/types/adapter-express/application-express.d.ts +70 -0
  58. package/lib/esm/types/adapter-express/application-express.d.ts.map +1 -0
  59. package/lib/esm/types/adapter-express/application-express.interface.d.ts +29 -0
  60. package/lib/esm/types/adapter-express/application-express.interface.d.ts.map +1 -0
  61. package/lib/esm/types/adapter-express/express-utils/base-middleware.d.ts +9 -0
  62. package/lib/esm/types/adapter-express/express-utils/base-middleware.d.ts.map +1 -0
  63. package/lib/esm/types/adapter-express/express-utils/constants.d.ts +39 -0
  64. package/lib/esm/types/adapter-express/express-utils/constants.d.ts.map +1 -0
  65. package/lib/esm/types/adapter-express/express-utils/content/httpContent.d.ts +8 -0
  66. package/lib/esm/types/adapter-express/express-utils/content/httpContent.d.ts.map +1 -0
  67. package/lib/esm/types/adapter-express/express-utils/decorators.d.ts +24 -0
  68. package/lib/esm/types/adapter-express/express-utils/decorators.d.ts.map +1 -0
  69. package/lib/esm/types/adapter-express/express-utils/httpResponseMessage.d.ts +16 -0
  70. package/lib/esm/types/adapter-express/express-utils/httpResponseMessage.d.ts.map +1 -0
  71. package/lib/esm/types/adapter-express/express-utils/index.d.ts +2 -0
  72. package/lib/esm/types/adapter-express/express-utils/index.d.ts.map +1 -0
  73. package/lib/esm/types/adapter-express/express-utils/interfaces.d.ts +76 -0
  74. package/lib/esm/types/adapter-express/express-utils/interfaces.d.ts.map +1 -0
  75. package/lib/esm/types/adapter-express/express-utils/inversify-express-server.d.ts +60 -0
  76. package/lib/esm/types/adapter-express/express-utils/inversify-express-server.d.ts.map +1 -0
  77. package/lib/esm/types/adapter-express/express-utils/utils.d.ts +10 -0
  78. package/lib/esm/types/adapter-express/express-utils/utils.d.ts.map +1 -0
  79. package/lib/esm/types/adapter-express/index.d.ts +4 -0
  80. package/lib/esm/types/adapter-express/index.d.ts.map +1 -0
  81. package/lib/esm/types/index.d.ts +2 -0
  82. package/lib/esm/types/index.d.ts.map +1 -0
  83. package/lib/package.json +153 -0
  84. package/package.json +153 -0
package/LICENSE.md ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2021 Richard Zampieri
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,107 @@
1
+ <a name="readme-top"></a>
2
+
3
+ <!-- PROJECT SHIELDS -->
4
+ [![Contributors][contributors-shield]][contributors-url]
5
+ [![Forks][forks-shield]][forks-url]
6
+ [![Stargazers][stars-shield]][stars-url]
7
+ [![Issues][issues-shield]][issues-url]
8
+ [![MIT License][license-shield]][license-url]
9
+ [![LinkedIn][linkedin-shield]][linkedin-url]
10
+
11
+ <!-- PROJECT LOGO -->
12
+ <br />
13
+ <div align="center">
14
+ <a href="https://github.com/othneildrew/Best-README-Template">
15
+ <img src="https://github.com/expressots/expressots/blob/main/media/expressots.png" alt="Logo" width="120">
16
+ </a>
17
+
18
+ <h3 align="center">ExpressoTS Framework</h3>
19
+
20
+ <p align="center">
21
+ Everything you need to know to build applications with ExpressoTS
22
+ <br />
23
+ <a href="https://doc.expresso-ts.com/"><strong>Explore the docs »</strong></a>
24
+ <br />
25
+ <br />
26
+ <a href="https://github.com/expressots/expressots/discussions">Let's discuss</a>
27
+ ·
28
+ <a href="https://github.com/expressots/expressots/issues">Report Bug</a>
29
+ ·
30
+ <a href="https://github.com/expressots/expressots/issues">Request Feature</a>
31
+ </p>
32
+ </div>
33
+
34
+ <!-- TABLE OF CONTENTS -->
35
+ <details>
36
+ <summary>Table of Contents</summary>
37
+ <ol>
38
+ <li><a href="#about-the-project">About The Project</a></li>
39
+ <li><a href="#getting-started">Getting Started</a></li>
40
+ <li><a href="#contributing">Contributing</a></li>
41
+ <li><a href="#support-the-project">Support the project</a></li>
42
+ <li><a href="#license">License</a></li>
43
+ </ol>
44
+ </details>
45
+
46
+ <!-- ABOUT THE PROJECT -->
47
+ # About The Project
48
+
49
+ ExpressoTS is a [Typescript](https://www.typescriptlang.org/) + [Node.js](https://nodejs.org/en/) lightweight framework for quick building scalable, easy to read and maintain, server-side applications 🐎
50
+
51
+ ## Getting Started
52
+
53
+ - Here is our [Site](https://expresso-ts.com/)
54
+ - You can find our [Documentation here](https://doc.expresso-ts.com/)
55
+ - Checkout our [First Steps documentation](https://doc.expresso-ts.com/docs/overview/first-steps)
56
+ - Our [CLI Documentation](https://doc.expresso-ts.com/docs/cli/overview)
57
+
58
+ ## Contributing
59
+
60
+ Welcome to the ExpressoTS community, a place bustling with innovative minds just like yours. We're absolutely thrilled to have you here!
61
+ ExpressoTS is more than just a TypeScript framework; it's a collective effort by developers who are passionate about creating a more efficient, secure, and robust web ecosystem. We firmly believe that the best ideas come from a diversity of perspectives, backgrounds, and skills.
62
+
63
+ Why Contribute to Documentation?
64
+
65
+ - **Share Knowledge**: If you've figured out something cool, why keep it to yourself?
66
+ - **Build Your Portfolio**: Contributing to an open-source project like ExpressoTS is a great way to showcase your skills.
67
+ - **Join a Network**: Get to know a community of like-minded developers.
68
+ - **Improve the Product**: Help us fill in the gaps, correct errors, or make complex topics easier to understand.
69
+
70
+ Ready to contribute?
71
+
72
+ - [Contributing Guidelines](https://github.com/expressots/expressots/blob/main/CONTRIBUTING.md)
73
+ - [How to Contribute](https://github.com/expressots/expressots/blob/main/CONTRIBUTING_HOWTO.md)
74
+ - [Coding Guidelines](https://github.com/rsaz/TypescriptCodingGuidelines)
75
+
76
+ ## Support the project
77
+
78
+ ExpressoTS is an independent open source project with ongoing development made possible thanks to your support. If you'd like to help, please consider:
79
+
80
+ - Become a **[sponsor on GitHub](https://github.com/sponsors/expressots)**
81
+ - Follow the **[organization](https://github.com/expressots)** on GitHub and Star ⭐ the project
82
+ - Subscribe to the Twitch channel: **[Richard Zampieri](https://www.twitch.tv/richardzampieri)**
83
+ - Join our **[Discord](https://discord.com/invite/PyPJfGK)**
84
+ - Contribute submitting **[issues and pull requests](https://github.com/expressots/expressots/issues)**
85
+ - Share the project with your friends and colleagues
86
+
87
+ ## License
88
+
89
+ Distributed under the MIT License. See [`LICENSE.txt`](https://github.com/expressots/expressots/blob/main/LICENSE) for more information.
90
+
91
+ <p align="right">(<a href="#readme-top">back to top</a>)</p>
92
+
93
+ <!-- MARKDOWN LINKS & IMAGES -->
94
+ <!-- https://www.markdownguide.org/basic-syntax/#reference-style-links -->
95
+ [contributors-shield]: https://img.shields.io/github/contributors/expressots/expressots?style=for-the-badge
96
+ [contributors-url]: https://github.com/expressots/expressots/graphs/contributors
97
+ [forks-shield]: https://img.shields.io/github/forks/expressots/expressots?style=for-the-badge
98
+ [forks-url]: https://github.com/expressots/expressots/forks
99
+ [stars-shield]: https://img.shields.io/github/stars/expressots/expressots?style=for-the-badge
100
+ [stars-url]: https://github.com/expressots/expressots/stargazers
101
+ [issues-shield]: https://img.shields.io/github/issues/expressots/expressots?style=for-the-badge
102
+ [issues-url]: https://github.com/expressots/expressots/issues
103
+ [license-shield]: https://img.shields.io/github/license/expressots/expressots?style=for-the-badge
104
+ [license-url]: https://github.com/expressots/expressots/blob/main/LICENSE
105
+ [linkedin-shield]: https://img.shields.io/badge/-LinkedIn-black.svg?style=for-the-badge&logo=linkedin&colorB=555
106
+ [linkedin-url]: https://www.linkedin.com/company/expresso-ts/
107
+ [product-screenshot]: images/screenshot.png
@@ -0,0 +1,8 @@
1
+
2
+
3
+ ## 0.0.1 (2023-09-05)
4
+
5
+
6
+ ### Bug Fixes
7
+
8
+ * testing commitlint ([0e78653](https://github.com/expressots/<<repo_name>>/commit/0e786539402f69fdca3fe5b684d850e523db7698))
package/lib/README.md ADDED
@@ -0,0 +1,107 @@
1
+ <a name="readme-top"></a>
2
+
3
+ <!-- PROJECT SHIELDS -->
4
+ [![Contributors][contributors-shield]][contributors-url]
5
+ [![Forks][forks-shield]][forks-url]
6
+ [![Stargazers][stars-shield]][stars-url]
7
+ [![Issues][issues-shield]][issues-url]
8
+ [![MIT License][license-shield]][license-url]
9
+ [![LinkedIn][linkedin-shield]][linkedin-url]
10
+
11
+ <!-- PROJECT LOGO -->
12
+ <br />
13
+ <div align="center">
14
+ <a href="https://github.com/othneildrew/Best-README-Template">
15
+ <img src="https://github.com/expressots/expressots/blob/main/media/expressots.png" alt="Logo" width="120">
16
+ </a>
17
+
18
+ <h3 align="center">ExpressoTS Framework</h3>
19
+
20
+ <p align="center">
21
+ Everything you need to know to build applications with ExpressoTS
22
+ <br />
23
+ <a href="https://doc.expresso-ts.com/"><strong>Explore the docs »</strong></a>
24
+ <br />
25
+ <br />
26
+ <a href="https://github.com/expressots/expressots/discussions">Let's discuss</a>
27
+ ·
28
+ <a href="https://github.com/expressots/expressots/issues">Report Bug</a>
29
+ ·
30
+ <a href="https://github.com/expressots/expressots/issues">Request Feature</a>
31
+ </p>
32
+ </div>
33
+
34
+ <!-- TABLE OF CONTENTS -->
35
+ <details>
36
+ <summary>Table of Contents</summary>
37
+ <ol>
38
+ <li><a href="#about-the-project">About The Project</a></li>
39
+ <li><a href="#getting-started">Getting Started</a></li>
40
+ <li><a href="#contributing">Contributing</a></li>
41
+ <li><a href="#support-the-project">Support the project</a></li>
42
+ <li><a href="#license">License</a></li>
43
+ </ol>
44
+ </details>
45
+
46
+ <!-- ABOUT THE PROJECT -->
47
+ # About The Project
48
+
49
+ ExpressoTS is a [Typescript](https://www.typescriptlang.org/) + [Node.js](https://nodejs.org/en/) lightweight framework for quick building scalable, easy to read and maintain, server-side applications 🐎
50
+
51
+ ## Getting Started
52
+
53
+ - Here is our [Site](https://expresso-ts.com/)
54
+ - You can find our [Documentation here](https://doc.expresso-ts.com/)
55
+ - Checkout our [First Steps documentation](https://doc.expresso-ts.com/docs/overview/first-steps)
56
+ - Our [CLI Documentation](https://doc.expresso-ts.com/docs/cli/overview)
57
+
58
+ ## Contributing
59
+
60
+ Welcome to the ExpressoTS community, a place bustling with innovative minds just like yours. We're absolutely thrilled to have you here!
61
+ ExpressoTS is more than just a TypeScript framework; it's a collective effort by developers who are passionate about creating a more efficient, secure, and robust web ecosystem. We firmly believe that the best ideas come from a diversity of perspectives, backgrounds, and skills.
62
+
63
+ Why Contribute to Documentation?
64
+
65
+ - **Share Knowledge**: If you've figured out something cool, why keep it to yourself?
66
+ - **Build Your Portfolio**: Contributing to an open-source project like ExpressoTS is a great way to showcase your skills.
67
+ - **Join a Network**: Get to know a community of like-minded developers.
68
+ - **Improve the Product**: Help us fill in the gaps, correct errors, or make complex topics easier to understand.
69
+
70
+ Ready to contribute?
71
+
72
+ - [Contributing Guidelines](https://github.com/expressots/expressots/blob/main/CONTRIBUTING.md)
73
+ - [How to Contribute](https://github.com/expressots/expressots/blob/main/CONTRIBUTING_HOWTO.md)
74
+ - [Coding Guidelines](https://github.com/rsaz/TypescriptCodingGuidelines)
75
+
76
+ ## Support the project
77
+
78
+ ExpressoTS is an independent open source project with ongoing development made possible thanks to your support. If you'd like to help, please consider:
79
+
80
+ - Become a **[sponsor on GitHub](https://github.com/sponsors/expressots)**
81
+ - Follow the **[organization](https://github.com/expressots)** on GitHub and Star ⭐ the project
82
+ - Subscribe to the Twitch channel: **[Richard Zampieri](https://www.twitch.tv/richardzampieri)**
83
+ - Join our **[Discord](https://discord.com/invite/PyPJfGK)**
84
+ - Contribute submitting **[issues and pull requests](https://github.com/expressots/expressots/issues)**
85
+ - Share the project with your friends and colleagues
86
+
87
+ ## License
88
+
89
+ Distributed under the MIT License. See [`LICENSE.txt`](https://github.com/expressots/expressots/blob/main/LICENSE) for more information.
90
+
91
+ <p align="right">(<a href="#readme-top">back to top</a>)</p>
92
+
93
+ <!-- MARKDOWN LINKS & IMAGES -->
94
+ <!-- https://www.markdownguide.org/basic-syntax/#reference-style-links -->
95
+ [contributors-shield]: https://img.shields.io/github/contributors/expressots/expressots?style=for-the-badge
96
+ [contributors-url]: https://github.com/expressots/expressots/graphs/contributors
97
+ [forks-shield]: https://img.shields.io/github/forks/expressots/expressots?style=for-the-badge
98
+ [forks-url]: https://github.com/expressots/expressots/forks
99
+ [stars-shield]: https://img.shields.io/github/stars/expressots/expressots?style=for-the-badge
100
+ [stars-url]: https://github.com/expressots/expressots/stargazers
101
+ [issues-shield]: https://img.shields.io/github/issues/expressots/expressots?style=for-the-badge
102
+ [issues-url]: https://github.com/expressots/expressots/issues
103
+ [license-shield]: https://img.shields.io/github/license/expressots/expressots?style=for-the-badge
104
+ [license-url]: https://github.com/expressots/expressots/blob/main/LICENSE
105
+ [linkedin-shield]: https://img.shields.io/badge/-LinkedIn-black.svg?style=for-the-badge&logo=linkedin&colorB=555
106
+ [linkedin-url]: https://www.linkedin.com/company/expresso-ts/
107
+ [product-screenshot]: images/screenshot.png
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,147 @@
1
+ "use strict";
2
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
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;
6
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
7
+ };
8
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
9
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
10
+ return new (P || (P = Promise))(function (resolve, reject) {
11
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
12
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
13
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
14
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
15
+ });
16
+ };
17
+ var __importDefault = (this && this.__importDefault) || function (mod) {
18
+ return (mod && mod.__esModule) ? mod : { "default": mod };
19
+ };
20
+ Object.defineProperty(exports, "__esModule", { value: true });
21
+ exports.ServerEnvironment = exports.AppExpress = void 0;
22
+ const inversify_binding_decorators_1 = require("inversify-binding-decorators");
23
+ const process_1 = __importDefault(require("process"));
24
+ const core_1 = require("@expressots/core");
25
+ const inversify_express_server_1 = require("./express-utils/inversify-express-server");
26
+ /**
27
+ * Enum representing possible server environments.
28
+ */
29
+ var ServerEnvironment;
30
+ (function (ServerEnvironment) {
31
+ ServerEnvironment["Development"] = "development";
32
+ ServerEnvironment["Production"] = "production";
33
+ })(ServerEnvironment || (exports.ServerEnvironment = ServerEnvironment = {}));
34
+ /**
35
+ * The Application class provides a way to configure and manage an Express application.
36
+ * @provide Application
37
+ */
38
+ let ApplicationExpress = class ApplicationExpress extends core_1.ApplicationBase {
39
+ constructor() {
40
+ super(...arguments);
41
+ this.middlewares = [];
42
+ }
43
+ configureServices() { }
44
+ postServerInitialization() { }
45
+ serverShutdown() { }
46
+ /**
47
+ * Handles process exit by calling serverShutdown and then exiting the process.
48
+ */
49
+ handleExit() {
50
+ this.serverShutdown();
51
+ process_1.default.exit(0);
52
+ }
53
+ /**
54
+ * Create and configure the Express application.
55
+ * @param container - The InversifyJS container.
56
+ * @param middlewares - An array of Express middlewares to be applied.
57
+ * @returns The configured Application instance.
58
+ */
59
+ create(container, middlewares = []) {
60
+ return __awaiter(this, void 0, void 0, function* () {
61
+ this.container = container;
62
+ yield Promise.resolve(this.configureServices());
63
+ const middleware = container.get(core_1.Middleware);
64
+ this.middlewares.push(...middlewares, ...middleware.getMiddlewares());
65
+ const expressServer = new inversify_express_server_1.InversifyExpressServer(container);
66
+ expressServer.setConfig((app) => {
67
+ this.middlewares.forEach((middleware) => {
68
+ app.use(middleware);
69
+ });
70
+ });
71
+ expressServer.setErrorConfig((app) => {
72
+ if (middleware.getErrorHandler()) {
73
+ app.use(middleware.getErrorHandler());
74
+ }
75
+ });
76
+ this.app = expressServer.build();
77
+ return this;
78
+ });
79
+ }
80
+ /**
81
+ * Start listening on the given port and environment.
82
+ * @param port - The port number to listen on.
83
+ * @param environment - The server environment.
84
+ * @param consoleMessage - Optional message to display in the console.
85
+ */
86
+ listen(port, environment, consoleMessage) {
87
+ return __awaiter(this, void 0, void 0, function* () {
88
+ this.port = port;
89
+ this.environment = environment;
90
+ this.app.set("env", environment);
91
+ this.app.listen(this.port, () => {
92
+ const console = this.container.get(core_1.Console);
93
+ console.messageServer(this.port, this.environment, consoleMessage);
94
+ ["SIGTERM", "SIGHUP", "SIGBREAK", "SIGQUIT", "SIGINT"].forEach((signal) => {
95
+ process_1.default.on(signal, this.handleExit.bind(this));
96
+ });
97
+ });
98
+ yield Promise.resolve(this.postServerInitialization());
99
+ });
100
+ }
101
+ /**
102
+ * Configures the application's view engine based on the provided configuration options.
103
+ *
104
+ * @public
105
+ * @method setEngine
106
+ * @template T - A generic type extending from RenderTemplateOptions.
107
+ *
108
+ * @param {T} options - An object of type T (must be an object that extends RenderTemplateOptions)
109
+ * that provides the configuration options for setting the view engine.
110
+ * This includes the extension name, view path, and the engine function itself.
111
+ */
112
+ setEngine(options) {
113
+ if ("extName" in options) {
114
+ const { extName, viewPath, engine } = options;
115
+ this.app.engine(extName, engine);
116
+ this.app.set("view engine", extName);
117
+ this.app.set("views", viewPath);
118
+ }
119
+ }
120
+ /**
121
+ * Verifies if the current environment is development.
122
+ *
123
+ * @returns A boolean value indicating whether the current environment is development or not.
124
+ */
125
+ isDevelopment() {
126
+ if (this.app) {
127
+ return this.app.get("env") === ServerEnvironment.Development;
128
+ }
129
+ this.container
130
+ .get(core_1.Logger)
131
+ .error("isDevelopment() method must be called on `PostServerInitialization`", "application");
132
+ return false;
133
+ }
134
+ /**
135
+ * Verifies if the current environment is production.
136
+ *
137
+ * @returns A boolean value indicating whether the current environment is production or not.
138
+ *
139
+ */
140
+ get ExpressApp() {
141
+ return this.app;
142
+ }
143
+ };
144
+ exports.AppExpress = ApplicationExpress;
145
+ exports.AppExpress = ApplicationExpress = __decorate([
146
+ (0, inversify_binding_decorators_1.provide)(ApplicationExpress)
147
+ ], ApplicationExpress);
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
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;
6
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
7
+ };
8
+ Object.defineProperty(exports, "__esModule", { value: true });
9
+ exports.BaseMiddleware = void 0;
10
+ const inversify_1 = require("inversify");
11
+ let BaseMiddleware = class BaseMiddleware {
12
+ bind(serviceIdentifier) {
13
+ return this.httpContext.container.bind(serviceIdentifier);
14
+ }
15
+ };
16
+ exports.BaseMiddleware = BaseMiddleware;
17
+ exports.BaseMiddleware = BaseMiddleware = __decorate([
18
+ (0, inversify_1.injectable)()
19
+ ], BaseMiddleware);
@@ -0,0 +1,46 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.DEFAULT_ROUTING_ROOT_PATH = exports.NO_CONTROLLERS_FOUND = exports.DUPLICATED_CONTROLLER_NAME = exports.HTTP_VERBS_ENUM = exports.PARAMETER_TYPE = exports.METADATA_KEY = exports.TYPE = void 0;
4
+ exports.TYPE = {
5
+ AuthProvider: Symbol.for("AuthProvider"),
6
+ Controller: Symbol.for("Controller"),
7
+ HttpContext: Symbol.for("HttpContext"),
8
+ };
9
+ exports.METADATA_KEY = {
10
+ controller: "inversify-express-utils:controller",
11
+ controllerMethod: "inversify-express-utils:controller-method",
12
+ controllerParameter: "inversify-express-utils:controller-parameter",
13
+ httpContext: "inversify-express-utils:httpcontext",
14
+ };
15
+ var PARAMETER_TYPE;
16
+ (function (PARAMETER_TYPE) {
17
+ PARAMETER_TYPE[PARAMETER_TYPE["REQUEST"] = 0] = "REQUEST";
18
+ PARAMETER_TYPE[PARAMETER_TYPE["RESPONSE"] = 1] = "RESPONSE";
19
+ PARAMETER_TYPE[PARAMETER_TYPE["PARAMS"] = 2] = "PARAMS";
20
+ PARAMETER_TYPE[PARAMETER_TYPE["QUERY"] = 3] = "QUERY";
21
+ PARAMETER_TYPE[PARAMETER_TYPE["BODY"] = 4] = "BODY";
22
+ PARAMETER_TYPE[PARAMETER_TYPE["HEADERS"] = 5] = "HEADERS";
23
+ PARAMETER_TYPE[PARAMETER_TYPE["COOKIES"] = 6] = "COOKIES";
24
+ PARAMETER_TYPE[PARAMETER_TYPE["NEXT"] = 7] = "NEXT";
25
+ PARAMETER_TYPE[PARAMETER_TYPE["PRINCIPAL"] = 8] = "PRINCIPAL";
26
+ })(PARAMETER_TYPE || (exports.PARAMETER_TYPE = PARAMETER_TYPE = {}));
27
+ var HTTP_VERBS_ENUM;
28
+ (function (HTTP_VERBS_ENUM) {
29
+ HTTP_VERBS_ENUM["all"] = "ALL";
30
+ HTTP_VERBS_ENUM["connect"] = "CONNECT";
31
+ HTTP_VERBS_ENUM["delete"] = "DELETE";
32
+ HTTP_VERBS_ENUM["get"] = "GET";
33
+ HTTP_VERBS_ENUM["head"] = "HEAD";
34
+ HTTP_VERBS_ENUM["options"] = "OPTIONS";
35
+ HTTP_VERBS_ENUM["patch"] = "PATCH";
36
+ HTTP_VERBS_ENUM["post"] = "POST";
37
+ HTTP_VERBS_ENUM["propfind"] = "PROPFIND";
38
+ HTTP_VERBS_ENUM["put"] = "PUT";
39
+ HTTP_VERBS_ENUM["trace"] = "TRACE";
40
+ })(HTTP_VERBS_ENUM || (exports.HTTP_VERBS_ENUM = HTTP_VERBS_ENUM = {}));
41
+ const DUPLICATED_CONTROLLER_NAME = (name) => `Two controllers cannot have the same name: ${name}`;
42
+ exports.DUPLICATED_CONTROLLER_NAME = DUPLICATED_CONTROLLER_NAME;
43
+ exports.NO_CONTROLLERS_FOUND = "No controllers" +
44
+ "have been found! Please ensure that you have register" +
45
+ "at least one Controller.";
46
+ exports.DEFAULT_ROUTING_ROOT_PATH = "/";
@@ -0,0 +1,12 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.HttpContent = void 0;
4
+ class HttpContent {
5
+ constructor() {
6
+ this._headers = {};
7
+ }
8
+ get headers() {
9
+ return this._headers;
10
+ }
11
+ }
12
+ exports.HttpContent = HttpContent;
@@ -0,0 +1,110 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.params = exports.Principal = exports.next = exports.cookies = exports.headers = exports.body = exports.query = exports.param = exports.response = exports.request = exports.httpMethod = exports.Delete = exports.Head = exports.Patch = exports.Put = exports.Post = exports.Get = exports.all = exports.controller = exports.injectHttpContext = void 0;
4
+ require("reflect-metadata");
5
+ const inversify_1 = require("inversify");
6
+ const constants_1 = require("./constants");
7
+ exports.injectHttpContext = (0, inversify_1.inject)(constants_1.TYPE.HttpContext);
8
+ function controller(path, ...middleware) {
9
+ return (target) => {
10
+ const currentMetadata = {
11
+ middleware,
12
+ path,
13
+ target,
14
+ };
15
+ (0, inversify_1.decorate)((0, inversify_1.injectable)(), target);
16
+ Reflect.defineMetadata(constants_1.METADATA_KEY.controller, currentMetadata, target);
17
+ const previousMetadata = Reflect.getMetadata(constants_1.METADATA_KEY.controller, Reflect) || [];
18
+ const newMetadata = [currentMetadata, ...previousMetadata];
19
+ Reflect.defineMetadata(constants_1.METADATA_KEY.controller, newMetadata, Reflect);
20
+ };
21
+ }
22
+ exports.controller = controller;
23
+ function all(path, ...middleware) {
24
+ return httpMethod("all", path, ...middleware);
25
+ }
26
+ exports.all = all;
27
+ function Get(path, ...middleware) {
28
+ return httpMethod("get", path, ...middleware);
29
+ }
30
+ exports.Get = Get;
31
+ function Post(path, ...middleware) {
32
+ return httpMethod("post", path, ...middleware);
33
+ }
34
+ exports.Post = Post;
35
+ function Put(path, ...middleware) {
36
+ return httpMethod("put", path, ...middleware);
37
+ }
38
+ exports.Put = Put;
39
+ function Patch(path, ...middleware) {
40
+ return httpMethod("patch", path, ...middleware);
41
+ }
42
+ exports.Patch = Patch;
43
+ function Head(path, ...middleware) {
44
+ return httpMethod("head", path, ...middleware);
45
+ }
46
+ exports.Head = Head;
47
+ function Delete(path, ...middleware) {
48
+ return httpMethod("delete", path, ...middleware);
49
+ }
50
+ exports.Delete = Delete;
51
+ function httpMethod(method, path, ...middleware) {
52
+ return (target, key) => {
53
+ const metadata = {
54
+ key,
55
+ method,
56
+ middleware,
57
+ path,
58
+ target,
59
+ };
60
+ let metadataList = [];
61
+ if (!Reflect.hasOwnMetadata(constants_1.METADATA_KEY.controllerMethod, target.constructor)) {
62
+ Reflect.defineMetadata(constants_1.METADATA_KEY.controllerMethod, metadataList, target.constructor);
63
+ }
64
+ else {
65
+ metadataList = Reflect.getOwnMetadata(constants_1.METADATA_KEY.controllerMethod, target.constructor);
66
+ }
67
+ metadataList.push(metadata);
68
+ };
69
+ }
70
+ exports.httpMethod = httpMethod;
71
+ /*
72
+ * Parameter Decorators
73
+ */
74
+ exports.request = paramDecoratorFactory(constants_1.PARAMETER_TYPE.REQUEST);
75
+ exports.response = paramDecoratorFactory(constants_1.PARAMETER_TYPE.RESPONSE);
76
+ exports.param = paramDecoratorFactory(constants_1.PARAMETER_TYPE.PARAMS);
77
+ exports.query = paramDecoratorFactory(constants_1.PARAMETER_TYPE.QUERY);
78
+ exports.body = paramDecoratorFactory(constants_1.PARAMETER_TYPE.BODY);
79
+ exports.headers = paramDecoratorFactory(constants_1.PARAMETER_TYPE.HEADERS);
80
+ exports.cookies = paramDecoratorFactory(constants_1.PARAMETER_TYPE.COOKIES);
81
+ exports.next = paramDecoratorFactory(constants_1.PARAMETER_TYPE.NEXT);
82
+ exports.Principal = paramDecoratorFactory(constants_1.PARAMETER_TYPE.PRINCIPAL);
83
+ function paramDecoratorFactory(parameterType) {
84
+ return (name) => params(parameterType, name);
85
+ }
86
+ function params(type, parameterName) {
87
+ return (target, methodName, index) => {
88
+ let metadataList = {};
89
+ let parameterMetadataList = [];
90
+ const parameterMetadata = {
91
+ index,
92
+ injectRoot: parameterName === undefined,
93
+ parameterName,
94
+ type,
95
+ };
96
+ if (!Reflect.hasOwnMetadata(constants_1.METADATA_KEY.controllerParameter, target.constructor)) {
97
+ parameterMetadataList.unshift(parameterMetadata);
98
+ }
99
+ else {
100
+ metadataList = Reflect.getOwnMetadata(constants_1.METADATA_KEY.controllerParameter, target.constructor);
101
+ if (metadataList[methodName]) {
102
+ parameterMetadataList = metadataList[methodName] || [];
103
+ }
104
+ parameterMetadataList.unshift(parameterMetadata);
105
+ }
106
+ metadataList[methodName] = parameterMetadataList;
107
+ Reflect.defineMetadata(constants_1.METADATA_KEY.controllerParameter, metadataList, target.constructor);
108
+ };
109
+ }
110
+ exports.params = params;
@@ -0,0 +1,31 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.HttpResponseMessage = void 0;
4
+ class HttpResponseMessage {
5
+ get headers() {
6
+ return this._headers;
7
+ }
8
+ set headers(headers) {
9
+ this._headers = headers;
10
+ }
11
+ get content() {
12
+ return this._content;
13
+ }
14
+ set content(value) {
15
+ this._content = value;
16
+ }
17
+ get statusCode() {
18
+ return this._statusCode;
19
+ }
20
+ set statusCode(code) {
21
+ if (code < 0 || code > 999) {
22
+ throw new Error(`${code} is not a valid status code`);
23
+ }
24
+ this._statusCode = code;
25
+ }
26
+ constructor(statusCode = 200) {
27
+ this._headers = {};
28
+ this.statusCode = statusCode;
29
+ }
30
+ }
31
+ exports.HttpResponseMessage = HttpResponseMessage;
@@ -0,0 +1,17 @@
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("./decorators"), exports);
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });