Skip to content

Commit 2e691d5

Browse files
committed
refactor: rename items for standardization and improve doc
1 parent 239501e commit 2e691d5

File tree

3 files changed

+15
-22
lines changed

3 files changed

+15
-22
lines changed

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@
7272
"devDependencies": {
7373
"@commitlint/cli": "^18.0.0",
7474
"@commitlint/config-conventional": "17.7.0",
75-
"@expressots/core": "2.10.0",
75+
"@expressots/core": "latest",
7676
"@release-it/conventional-changelog": "7.0.1",
7777
"@types/express": "4.17.21",
7878
"@types/jest": "29.5.0",

src/adapter-express/application-express.base.ts

+10-16
Original file line numberDiff line numberDiff line change
@@ -23,36 +23,30 @@ import { provide } from "inversify-binding-decorators";
2323
@provide(ApplicationBase)
2424
export abstract class ApplicationBase {
2525
/**
26-
* Method to configure services that should be initialized
27-
* before the server starts. It must be implemented by the
28-
* extending class to set up necessary services or configurations.
29-
* Can return a Promise for async configuration.
26+
* Implement this method to set up required services or configurations before
27+
* the server starts. This is essential for initializing dependencies or settings
28+
* necessary for server operation. Supports asynchronous setup with a Promise.
3029
*
3130
* @abstract
3231
* @returns {void | Promise<void>}
3332
*/
3433
protected abstract configureServices(): void | Promise<void>;
3534

3635
/**
37-
* Method to configure services or actions that should be executed
38-
* after the server starts. It allows the extending class to perform
39-
* any necessary operations once the server is up and running.
40-
* Can return a Promise for async execution.
36+
* Implement this method to execute actions or configurations after the server
37+
* has started. Use this for operations that need to run once the server is
38+
* operational. Supports asynchronous execution with a Promise.
4139
*
4240
* @abstract
4341
* @returns {void | Promise<void>}
4442
*/
4543
protected abstract postServerInitialization(): void | Promise<void>;
4644

4745
/**
48-
* Method to perform any necessary actions or cleanup after the server
49-
* is shutting down. This might include closing database connections,
50-
* stopping background tasks, or other cleanup activities. It provides
51-
* a clean exit point for the server.
52-
* Can return a Promise for async cleanup.
53-
*
54-
* @abstract
55-
* @returns {void | Promise<void>}
46+
* Implement this method to handle cleanup and final actions when the server
47+
* is shutting down. Ideal for closing resources, stopping tasks, or other
48+
* cleanup procedures to ensure a graceful server shutdown. Supports asynchronous
49+
* cleanup with a Promise.
5650
*/
5751
protected abstract serverShutdown(): void | Promise<void>;
5852
}

src/adapter-express/application-express.ts

+4-5
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ class AppExpress extends ApplicationBase implements IWebServer {
3939
private container: Container;
4040
private globalPrefix: string = "/";
4141
private middlewares: Array<ExpressHandler | MiddlewareConfig | ExpressoMiddleware> = [];
42+
private console: Console;
4243

4344
protected configureServices(): void | Promise<void> {}
4445
protected postServerInitialization(): void | Promise<void> {}
@@ -58,6 +59,7 @@ class AppExpress extends ApplicationBase implements IWebServer {
5859
*/
5960
async configure(container: Container): Promise<void> {
6061
this.container = container;
62+
this.console = this.container.get(Console);
6163
}
6264

6365
/**
@@ -138,17 +140,14 @@ class AppExpress extends ApplicationBase implements IWebServer {
138140
environment: ServerEnvironment,
139141
consoleMessage?: IApplicationMessageToConsole,
140142
): Promise<void> {
141-
/* Initializes the application and executes the middleware pipeline */
142143
await this.init();
143144

144-
/* Sets the port and environment */
145145
this.port = port;
146146
this.environment = environment;
147147
this.app.set("env", environment);
148148

149149
this.app.listen(this.port, () => {
150-
const console: Console = this.container.get<Console>(Console);
151-
console.messageServer(this.port, this.environment, consoleMessage);
150+
this.console.messageServer(this.port, this.environment, consoleMessage);
152151

153152
(["SIGTERM", "SIGHUP", "SIGBREAK", "SIGQUIT", "SIGINT"] as Array<NodeJS.Signals>).forEach(
154153
(signal) => {
@@ -157,7 +156,7 @@ class AppExpress extends ApplicationBase implements IWebServer {
157156
);
158157
});
159158

160-
await Promise.resolve(this.postServerInitialization());
159+
await this.postServerInitialization();
161160
}
162161

163162
/**

0 commit comments

Comments
 (0)