@expressots/adapter-express 3.0.0-beta.3 → 3.0.0-beta.4
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.
package/lib/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,28 @@
|
|
|
1
|
+
## [3.0.0-beta.4](https://github.com/expressots/adapter-express/compare/3.0.0-beta.3...3.0.0) (2024-12-03)
|
|
2
|
+
|
|
3
|
+
### Code Refactoring
|
|
4
|
+
|
|
5
|
+
- app express class with async methods ([5c9ea2b](https://github.com/expressots/adapter-express/commit/5c9ea2b6cac9fa6455d140c0d0ce052712fa8251))
|
|
6
|
+
|
|
7
|
+
### Tests
|
|
8
|
+
|
|
9
|
+
- update tests for globalConfiguration, isDevelopment, getHttpServer, serverShutdown ([17b7d92](https://github.com/expressots/adapter-express/commit/17b7d92e87f4ad0d14a386e8351c723e1392a5c3))
|
|
10
|
+
|
|
11
|
+
## [3.0.0-beta.3](https://github.com/expressots/adapter-express/compare/3.0.0-beta.2...3.0.0) (2024-11-28)
|
|
12
|
+
|
|
13
|
+
### Features
|
|
14
|
+
|
|
15
|
+
- create server instance http and add close method for graceful shutdown ([be16011](https://github.com/expressots/adapter-express/commit/be16011f4686ce513bc254b8db9ca8abe2d79324))
|
|
16
|
+
|
|
17
|
+
### Bug Fixes
|
|
18
|
+
|
|
19
|
+
- update error message in getHttpServer method for clarity ([dc4f5a3](https://github.com/expressots/adapter-express/commit/dc4f5a30322e00efa74283445d1d46fabb61ffe1))
|
|
20
|
+
- update middleware path handling to include global prefix ([b7bffc5](https://github.com/expressots/adapter-express/commit/b7bffc5d2217ace1097ee7ef28dc28176de8e256))
|
|
21
|
+
|
|
22
|
+
### Tests
|
|
23
|
+
|
|
24
|
+
- add unit tests for serverShutdown and setGlobalRoutePrefix methods ([2c1ad63](https://github.com/expressots/adapter-express/commit/2c1ad633f33374d09c3b8ea2b004cdc94f207da7))
|
|
25
|
+
|
|
1
26
|
## [3.0.0-beta.2](https://github.com/expressots/adapter-express/compare/3.0.0-beta.1...3.0.0) (2024-11-24)
|
|
2
27
|
|
|
3
28
|
### Features
|
|
@@ -31,7 +31,6 @@ const fs_1 = __importDefault(require("fs"));
|
|
|
31
31
|
const process_1 = __importStar(require("process"));
|
|
32
32
|
const core_1 = require("@expressots/core");
|
|
33
33
|
const shared_1 = require("@expressots/shared");
|
|
34
|
-
const application_express_base_1 = require("./application-express.base");
|
|
35
34
|
const http_status_middleware_1 = require("./express-utils/http-status-middleware");
|
|
36
35
|
const inversify_express_server_1 = require("./express-utils/inversify-express-server");
|
|
37
36
|
const engine_1 = require("./render/engine");
|
|
@@ -46,9 +45,8 @@ const engine_1 = require("./render/engine");
|
|
|
46
45
|
* @method setEngine - Configures the application's view engine based on the provided configuration options.
|
|
47
46
|
* @method isDevelopment - Verifies if the current environment is development.
|
|
48
47
|
*/
|
|
49
|
-
class AppExpress
|
|
48
|
+
class AppExpress {
|
|
50
49
|
constructor() {
|
|
51
|
-
super();
|
|
52
50
|
this.logger = new core_1.Logger();
|
|
53
51
|
this.console = new core_1.Console();
|
|
54
52
|
this.serverInstance = null;
|
|
@@ -57,15 +55,53 @@ class AppExpress extends application_express_base_1.ApplicationBase {
|
|
|
57
55
|
this.renderOptions = {};
|
|
58
56
|
this.globalConfiguration();
|
|
59
57
|
}
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
58
|
+
/**
|
|
59
|
+
* Implement this method to set up global configurations for the server.
|
|
60
|
+
* This method is called before any other server initialization methods.
|
|
61
|
+
* Use this method to configure global settings that apply to the entire
|
|
62
|
+
* server application. Supports asynchronous setup with a Promise.
|
|
63
|
+
*
|
|
64
|
+
* @abstract
|
|
65
|
+
* @returns {void | Promise<void>}
|
|
66
|
+
* @public API
|
|
67
|
+
*/
|
|
68
|
+
async globalConfiguration() { }
|
|
69
|
+
/**
|
|
70
|
+
* Implement this method to set up required services or configurations before
|
|
71
|
+
* the server starts. This is essential for initializing dependencies or settings
|
|
72
|
+
* necessary for server operation. Supports asynchronous setup with a Promise.
|
|
73
|
+
*
|
|
74
|
+
* @abstract
|
|
75
|
+
* @returns {void | Promise<void>}
|
|
76
|
+
* @public API
|
|
77
|
+
*/
|
|
78
|
+
async configureServices() { }
|
|
79
|
+
/**
|
|
80
|
+
* Implement this method to execute actions or configurations after the server
|
|
81
|
+
* has started. Use this for operations that need to run once the server is
|
|
82
|
+
* operational. Supports asynchronous execution with a Promise.
|
|
83
|
+
*
|
|
84
|
+
* @abstract
|
|
85
|
+
* @returns {void | Promise<void>}
|
|
86
|
+
* @public API
|
|
87
|
+
*/
|
|
88
|
+
async postServerInitialization() { }
|
|
89
|
+
/**
|
|
90
|
+
* Implement this method to handle cleanup and final actions when the server
|
|
91
|
+
* is shutting down. Ideal for closing resources, stopping tasks, or other
|
|
92
|
+
* cleanup procedures to ensure a graceful server shutdown. Supports asynchronous
|
|
93
|
+
* cleanup with a Promise.
|
|
94
|
+
*
|
|
95
|
+
* @abstract
|
|
96
|
+
* @returns {void | Promise<void>}
|
|
97
|
+
* @public API
|
|
98
|
+
*/
|
|
99
|
+
async serverShutdown() { }
|
|
64
100
|
/**
|
|
65
101
|
* Handles process exit by calling serverShutdown and then exiting the process.
|
|
66
102
|
*/
|
|
67
|
-
handleExit() {
|
|
68
|
-
this.serverShutdown();
|
|
103
|
+
async handleExit() {
|
|
104
|
+
await this.serverShutdown();
|
|
69
105
|
process_1.default.exit(0);
|
|
70
106
|
}
|
|
71
107
|
/**
|
|
@@ -190,6 +226,7 @@ class AppExpress extends application_express_base_1.ApplicationBase {
|
|
|
190
226
|
});
|
|
191
227
|
});
|
|
192
228
|
await this.postServerInitialization();
|
|
229
|
+
return this;
|
|
193
230
|
}
|
|
194
231
|
/**
|
|
195
232
|
* Sets the global route prefix for the application.
|
|
@@ -197,7 +234,7 @@ class AppExpress extends application_express_base_1.ApplicationBase {
|
|
|
197
234
|
* @param {string} prefix - The prefix to use for all routes.
|
|
198
235
|
* @public API
|
|
199
236
|
*/
|
|
200
|
-
setGlobalRoutePrefix(prefix) {
|
|
237
|
+
async setGlobalRoutePrefix(prefix) {
|
|
201
238
|
this.globalPrefix = prefix;
|
|
202
239
|
}
|
|
203
240
|
/**
|
|
@@ -247,7 +284,7 @@ class AppExpress extends application_express_base_1.ApplicationBase {
|
|
|
247
284
|
* @returns A boolean value indicating whether the current environment is development or not.
|
|
248
285
|
* @public API
|
|
249
286
|
*/
|
|
250
|
-
isDevelopment() {
|
|
287
|
+
async isDevelopment() {
|
|
251
288
|
if (this.app) {
|
|
252
289
|
return this.app.get("env") === "development";
|
|
253
290
|
}
|
|
@@ -270,7 +307,7 @@ class AppExpress extends application_express_base_1.ApplicationBase {
|
|
|
270
307
|
* ```
|
|
271
308
|
* @public API
|
|
272
309
|
*/
|
|
273
|
-
initEnvironment(environment, options) {
|
|
310
|
+
async initEnvironment(environment, options) {
|
|
274
311
|
this.environment = environment;
|
|
275
312
|
if (options === undefined) {
|
|
276
313
|
(0, shared_1.config)({ path: ".env" });
|
|
@@ -298,37 +335,11 @@ class AppExpress extends application_express_base_1.ApplicationBase {
|
|
|
298
335
|
* @public API
|
|
299
336
|
*/
|
|
300
337
|
async getHttpServer() {
|
|
301
|
-
if (!this.
|
|
302
|
-
this.logger.error("
|
|
303
|
-
throw new Error("
|
|
338
|
+
if (!this.serverInstance) {
|
|
339
|
+
this.logger.error("Server instance not initialized yet", "adapter-express");
|
|
340
|
+
throw new Error("Server instance not initialized yet");
|
|
304
341
|
}
|
|
305
|
-
return this.
|
|
306
|
-
}
|
|
307
|
-
/**
|
|
308
|
-
* Close the server instance.
|
|
309
|
-
* @returns A promise that resolves when the server is closed.
|
|
310
|
-
* @public API
|
|
311
|
-
*/
|
|
312
|
-
close(enableLog = false) {
|
|
313
|
-
return new Promise((resolve, reject) => {
|
|
314
|
-
if (this.serverInstance) {
|
|
315
|
-
this.serverInstance.close((err) => {
|
|
316
|
-
if (err) {
|
|
317
|
-
if (enableLog)
|
|
318
|
-
this.logger.error(`Error closing server: ${err.message}`, "adapter-express");
|
|
319
|
-
reject(err);
|
|
320
|
-
}
|
|
321
|
-
else {
|
|
322
|
-
if (enableLog)
|
|
323
|
-
this.logger.info("Server closed successfully", "adapter-express");
|
|
324
|
-
resolve();
|
|
325
|
-
}
|
|
326
|
-
});
|
|
327
|
-
}
|
|
328
|
-
else {
|
|
329
|
-
resolve();
|
|
330
|
-
}
|
|
331
|
-
});
|
|
342
|
+
return Promise.resolve(this.serverInstance);
|
|
332
343
|
}
|
|
333
344
|
}
|
|
334
345
|
exports.AppExpress = AppExpress;
|
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { AppContainer, IConsoleMessage,
|
|
3
|
-
import {
|
|
1
|
+
import { Server as HTTPServer } from "http";
|
|
2
|
+
import { AppContainer, IConsoleMessage, IMiddleware, ProviderManager } from "@expressots/core";
|
|
3
|
+
import { Env, IWebServerPublic, RenderEngine, Server } from "@expressots/shared";
|
|
4
4
|
import { interfaces } from "../di/di.interfaces";
|
|
5
|
-
import { ApplicationBase } from "./application-express.base";
|
|
6
5
|
/**
|
|
7
6
|
* The AppExpress class provides methods for configuring and running an Express application.
|
|
8
7
|
* @class AppExpress
|
|
@@ -14,7 +13,7 @@ import { ApplicationBase } from "./application-express.base";
|
|
|
14
13
|
* @method setEngine - Configures the application's view engine based on the provided configuration options.
|
|
15
14
|
* @method isDevelopment - Verifies if the current environment is development.
|
|
16
15
|
*/
|
|
17
|
-
export declare class AppExpress
|
|
16
|
+
export declare class AppExpress implements Server.IWebServer {
|
|
18
17
|
private logger;
|
|
19
18
|
private console;
|
|
20
19
|
private app;
|
|
@@ -28,10 +27,48 @@ export declare class AppExpress extends ApplicationBase implements Server.IWebSe
|
|
|
28
27
|
private providerManager;
|
|
29
28
|
private renderOptions;
|
|
30
29
|
constructor();
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
30
|
+
/**
|
|
31
|
+
* Implement this method to set up global configurations for the server.
|
|
32
|
+
* This method is called before any other server initialization methods.
|
|
33
|
+
* Use this method to configure global settings that apply to the entire
|
|
34
|
+
* server application. Supports asynchronous setup with a Promise.
|
|
35
|
+
*
|
|
36
|
+
* @abstract
|
|
37
|
+
* @returns {void | Promise<void>}
|
|
38
|
+
* @public API
|
|
39
|
+
*/
|
|
40
|
+
protected globalConfiguration(): Promise<void>;
|
|
41
|
+
/**
|
|
42
|
+
* Implement this method to set up required services or configurations before
|
|
43
|
+
* the server starts. This is essential for initializing dependencies or settings
|
|
44
|
+
* necessary for server operation. Supports asynchronous setup with a Promise.
|
|
45
|
+
*
|
|
46
|
+
* @abstract
|
|
47
|
+
* @returns {void | Promise<void>}
|
|
48
|
+
* @public API
|
|
49
|
+
*/
|
|
50
|
+
protected configureServices(): Promise<void>;
|
|
51
|
+
/**
|
|
52
|
+
* Implement this method to execute actions or configurations after the server
|
|
53
|
+
* has started. Use this for operations that need to run once the server is
|
|
54
|
+
* operational. Supports asynchronous execution with a Promise.
|
|
55
|
+
*
|
|
56
|
+
* @abstract
|
|
57
|
+
* @returns {void | Promise<void>}
|
|
58
|
+
* @public API
|
|
59
|
+
*/
|
|
60
|
+
protected postServerInitialization(): Promise<void>;
|
|
61
|
+
/**
|
|
62
|
+
* Implement this method to handle cleanup and final actions when the server
|
|
63
|
+
* is shutting down. Ideal for closing resources, stopping tasks, or other
|
|
64
|
+
* cleanup procedures to ensure a graceful server shutdown. Supports asynchronous
|
|
65
|
+
* cleanup with a Promise.
|
|
66
|
+
*
|
|
67
|
+
* @abstract
|
|
68
|
+
* @returns {void | Promise<void>}
|
|
69
|
+
* @public API
|
|
70
|
+
*/
|
|
71
|
+
protected serverShutdown(): Promise<void>;
|
|
35
72
|
/**
|
|
36
73
|
* Handles process exit by calling serverShutdown and then exiting the process.
|
|
37
74
|
*/
|
|
@@ -79,14 +116,14 @@ export declare class AppExpress extends ApplicationBase implements Server.IWebSe
|
|
|
79
116
|
* @param appInfo - Optional message to display the app name and version.
|
|
80
117
|
* @public API
|
|
81
118
|
*/
|
|
82
|
-
listen(port: number | string, appInfo?: IConsoleMessage): Promise<
|
|
119
|
+
listen(port: number | string, appInfo?: IConsoleMessage): Promise<IWebServerPublic>;
|
|
83
120
|
/**
|
|
84
121
|
* Sets the global route prefix for the application.
|
|
85
122
|
* @method setGlobalRoutePrefix
|
|
86
123
|
* @param {string} prefix - The prefix to use for all routes.
|
|
87
124
|
* @public API
|
|
88
125
|
*/
|
|
89
|
-
setGlobalRoutePrefix(prefix: string): void
|
|
126
|
+
setGlobalRoutePrefix(prefix: string): Promise<void>;
|
|
90
127
|
/**
|
|
91
128
|
* Configures the application's view engine based on the provided configuration options.
|
|
92
129
|
*/
|
|
@@ -106,7 +143,7 @@ export declare class AppExpress extends ApplicationBase implements Server.IWebSe
|
|
|
106
143
|
* @returns A boolean value indicating whether the current environment is development or not.
|
|
107
144
|
* @public API
|
|
108
145
|
*/
|
|
109
|
-
|
|
146
|
+
isDevelopment(): Promise<boolean>;
|
|
110
147
|
/**
|
|
111
148
|
* Load environment variables from the specified file based on the environment configuration.
|
|
112
149
|
* @param environment - The environment to load configuration for.
|
|
@@ -123,17 +160,11 @@ export declare class AppExpress extends ApplicationBase implements Server.IWebSe
|
|
|
123
160
|
* ```
|
|
124
161
|
* @public API
|
|
125
162
|
*/
|
|
126
|
-
initEnvironment(environment: Env.Environment, options?: Env.IEnvironment): void
|
|
163
|
+
initEnvironment(environment: Env.Environment, options?: Env.IEnvironment): Promise<void>;
|
|
127
164
|
/**
|
|
128
165
|
* Get the underlying HTTP server. (default: Express.js)
|
|
129
166
|
* @returns The underlying HTTP server after initialization.
|
|
130
167
|
* @public API
|
|
131
168
|
*/
|
|
132
|
-
getHttpServer(): Promise<
|
|
133
|
-
/**
|
|
134
|
-
* Close the server instance.
|
|
135
|
-
* @returns A promise that resolves when the server is closed.
|
|
136
|
-
* @public API
|
|
137
|
-
*/
|
|
138
|
-
close(enableLog?: boolean): Promise<void>;
|
|
169
|
+
getHttpServer(): Promise<HTTPServer>;
|
|
139
170
|
}
|
package/lib/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@expressots/adapter-express",
|
|
3
|
-
"version": "3.0.0-beta.
|
|
3
|
+
"version": "3.0.0-beta.4",
|
|
4
4
|
"description": "Expressots - modern, fast, lightweight nodejs web framework (@adapter-express)",
|
|
5
5
|
"author": "",
|
|
6
6
|
"main": "./lib/cjs/index.js",
|
|
@@ -66,14 +66,14 @@
|
|
|
66
66
|
"reflect-metadata": "0.2.2"
|
|
67
67
|
},
|
|
68
68
|
"devDependencies": {
|
|
69
|
-
"@codecov/vite-plugin": "
|
|
69
|
+
"@codecov/vite-plugin": "0.0.1-beta.6",
|
|
70
70
|
"@commitlint/cli": "19.2.1",
|
|
71
71
|
"@commitlint/config-conventional": "19.2.2",
|
|
72
|
-
"@expressots/core": "3.0.0-beta.
|
|
73
|
-
"@expressots/shared": "3.0.0-beta.
|
|
72
|
+
"@expressots/core": "3.0.0-beta.4",
|
|
73
|
+
"@expressots/shared": "3.0.0-beta.4",
|
|
74
74
|
"@release-it/conventional-changelog": "8.0.1",
|
|
75
75
|
"@types/express": "4.17.21",
|
|
76
|
-
"@types/jest": "
|
|
76
|
+
"@types/jest": "29.5.14",
|
|
77
77
|
"@types/node": "20.14.10",
|
|
78
78
|
"@typescript-eslint/eslint-plugin": "7.16.1",
|
|
79
79
|
"@typescript-eslint/parser": "7.16.1",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@expressots/adapter-express",
|
|
3
|
-
"version": "3.0.0-beta.
|
|
3
|
+
"version": "3.0.0-beta.4",
|
|
4
4
|
"description": "Expressots - modern, fast, lightweight nodejs web framework (@adapter-express)",
|
|
5
5
|
"author": "",
|
|
6
6
|
"main": "./lib/cjs/index.js",
|
|
@@ -66,14 +66,14 @@
|
|
|
66
66
|
"reflect-metadata": "0.2.2"
|
|
67
67
|
},
|
|
68
68
|
"devDependencies": {
|
|
69
|
-
"@codecov/vite-plugin": "
|
|
69
|
+
"@codecov/vite-plugin": "0.0.1-beta.6",
|
|
70
70
|
"@commitlint/cli": "19.2.1",
|
|
71
71
|
"@commitlint/config-conventional": "19.2.2",
|
|
72
|
-
"@expressots/core": "3.0.0-beta.
|
|
73
|
-
"@expressots/shared": "3.0.0-beta.
|
|
72
|
+
"@expressots/core": "3.0.0-beta.4",
|
|
73
|
+
"@expressots/shared": "3.0.0-beta.4",
|
|
74
74
|
"@release-it/conventional-changelog": "8.0.1",
|
|
75
75
|
"@types/express": "4.17.21",
|
|
76
|
-
"@types/jest": "
|
|
76
|
+
"@types/jest": "29.5.14",
|
|
77
77
|
"@types/node": "20.14.10",
|
|
78
78
|
"@typescript-eslint/eslint-plugin": "7.16.1",
|
|
79
79
|
"@typescript-eslint/parser": "7.16.1",
|