opticore-webapp 1.0.68 → 1.0.70
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/dist/index.cjs +161 -892
- package/dist/index.d.cts +20 -185
- package/dist/index.d.ts +20 -185
- package/dist/index.js +164 -899
- package/dist/utils/translations/message.translation.en.json +24 -3
- package/dist/utils/translations/message.translation.fr.json +3 -3
- package/package.json +8 -9
package/dist/index.d.cts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
+
import * as http from 'http';
|
|
1
2
|
import { Server } from 'http';
|
|
2
|
-
import { TDependency } from 'opticore-dependency-inject';
|
|
3
3
|
import { TFeatureRoutes } from 'opticore-router';
|
|
4
|
+
import { TDependency } from 'opticore-dependency-inject';
|
|
4
5
|
import { express } from 'opticore-express';
|
|
5
6
|
import { LoggerCore } from 'opticore-logger';
|
|
6
7
|
import { CorsOptions } from 'cors';
|
|
@@ -10,211 +11,45 @@ interface WebServerConstructorInterface {
|
|
|
10
11
|
loggerConfig: LoggerCore;
|
|
11
12
|
localLanguage: string;
|
|
12
13
|
environmentPath: any;
|
|
13
|
-
corsOriginOptions?: Partial<CorsOptions
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
type TServerStatus = "READY" | "RELOADING" | "BLOCKED" | "ERROR" | "STARTING" | "STOPPING";
|
|
17
|
-
|
|
18
|
-
interface IServerStateInfo {
|
|
19
|
-
status: TServerStatus;
|
|
20
|
-
isRunning: boolean;
|
|
21
|
-
host: string;
|
|
22
|
-
port: number;
|
|
23
|
-
language: string;
|
|
24
|
-
watcherEnabled: boolean;
|
|
25
|
-
watcherActive?: boolean;
|
|
26
|
-
routesCount: number;
|
|
27
|
-
dependenciesCount: number;
|
|
28
|
-
startTime?: Date;
|
|
29
|
-
currentTime?: Date;
|
|
30
|
-
uptime?: number;
|
|
31
|
-
memoryUsage?: NodeJS.MemoryUsage;
|
|
32
|
-
uptimeFormatted?: string;
|
|
33
|
-
pid?: any;
|
|
34
|
-
platform?: any;
|
|
35
|
-
nodeVersion?: any;
|
|
36
|
-
cwd?: any;
|
|
14
|
+
corsOriginOptions?: Partial<CorsOptions> | null;
|
|
37
15
|
}
|
|
38
16
|
|
|
39
17
|
declare class WebServerCore {
|
|
40
18
|
private serverUtility;
|
|
41
19
|
private expressApp;
|
|
42
|
-
private fileWatcher;
|
|
43
20
|
private readonly localLanguage;
|
|
44
21
|
private readonly loggerConfig;
|
|
45
22
|
private readonly routerExpressApp;
|
|
46
|
-
private readonly
|
|
23
|
+
private readonly getEnvironmentValue;
|
|
47
24
|
private readonly environmentPath;
|
|
48
25
|
private serverListenEvent;
|
|
49
|
-
private
|
|
50
|
-
private currentDependencies;
|
|
51
|
-
private server;
|
|
52
|
-
private errorEmitter;
|
|
53
|
-
private isWatcherEnabled;
|
|
54
|
-
private serverStatus;
|
|
55
|
-
private serverStartTime;
|
|
26
|
+
private dependenciesRegistered;
|
|
56
27
|
constructor(paramsConstructor: WebServerConstructorInterface);
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
private setupErrorHandling;
|
|
62
|
-
/**
|
|
63
|
-
* Setup server events
|
|
64
|
-
*/
|
|
65
|
-
private setupServerEvents;
|
|
66
|
-
/**
|
|
67
|
-
* Initialize file watcher
|
|
68
|
-
*/
|
|
69
|
-
private initializeFileWatcher;
|
|
70
|
-
/**
|
|
71
|
-
* Setup watcher events
|
|
72
|
-
*/
|
|
73
|
-
private setupWatcherEvents;
|
|
74
|
-
/**
|
|
75
|
-
* Handle file changes detected by watcher
|
|
76
|
-
*/
|
|
77
|
-
private handleFileChange;
|
|
78
|
-
/**
|
|
79
|
-
* Handle hot reload requested by watcher
|
|
80
|
-
*/
|
|
81
|
-
private handleHotReload;
|
|
82
|
-
/**
|
|
83
|
-
* Handle watcher errors
|
|
84
|
-
*/
|
|
85
|
-
private handleWatcherError;
|
|
86
|
-
/**
|
|
87
|
-
* Notify file change without action
|
|
88
|
-
*/
|
|
89
|
-
private notifyFileChange;
|
|
90
|
-
/**
|
|
91
|
-
* Reload environment configuration
|
|
92
|
-
*/
|
|
93
|
-
private reloadEnvironmentConfig;
|
|
94
|
-
/**
|
|
95
|
-
* Execute hot reload for environment files
|
|
96
|
-
*/
|
|
97
|
-
private executeHotReloadEnvironment;
|
|
98
|
-
/**
|
|
99
|
-
* Reload configuration files
|
|
100
|
-
*/
|
|
101
|
-
private reloadConfigurationFiles;
|
|
102
|
-
/**
|
|
103
|
-
* Execute hot reload for config files
|
|
104
|
-
*/
|
|
105
|
-
private executeHotReloadConfig;
|
|
106
|
-
/**
|
|
107
|
-
* Reload application routes
|
|
108
|
-
*/
|
|
109
|
-
private reloadApplicationRoutes;
|
|
110
|
-
/**
|
|
111
|
-
* Execute hot reload for routes
|
|
112
|
-
*/
|
|
113
|
-
private executeHotReloadRoutes;
|
|
114
|
-
/**
|
|
115
|
-
* Execute hot reload for dependencies
|
|
116
|
-
*/
|
|
117
|
-
private executeHotReloadDependencies;
|
|
28
|
+
registerDependencies(dependencies: TDependency[]): void;
|
|
29
|
+
onStartServer(routers: TFeatureRoutes[], databaseCallback: (env: any) => void, dependenciesProvider?: TDependency[]): Server<typeof http.IncomingMessage, typeof http.ServerResponse> | undefined;
|
|
30
|
+
onListeningOnServerEvent(serverWeb: Server): void;
|
|
31
|
+
onRequestOnServerEvent(serverWeb: Server): void;
|
|
118
32
|
/**
|
|
119
|
-
*
|
|
33
|
+
*
|
|
34
|
+
* @private
|
|
120
35
|
*/
|
|
121
|
-
private
|
|
36
|
+
private loadTranslationFiles;
|
|
122
37
|
/**
|
|
123
|
-
*
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
/**
|
|
127
|
-
* Reload router for specific file
|
|
128
|
-
*/
|
|
129
|
-
private reloadRouterForFile;
|
|
130
|
-
/**
|
|
131
|
-
* Reload configurations
|
|
132
|
-
*/
|
|
133
|
-
private reloadConfigurations;
|
|
134
|
-
/**
|
|
135
|
-
* Reload dependencies
|
|
136
|
-
*/
|
|
137
|
-
private reloadDependencies;
|
|
138
|
-
/**
|
|
139
|
-
* Register routes
|
|
38
|
+
*
|
|
39
|
+
* @param allFeatureRoutes
|
|
40
|
+
* @private
|
|
140
41
|
*/
|
|
141
42
|
private registerRoutes;
|
|
142
43
|
/**
|
|
143
|
-
*
|
|
44
|
+
*
|
|
45
|
+
* @private
|
|
144
46
|
*/
|
|
145
|
-
private
|
|
47
|
+
private stackTraceErrorHandling;
|
|
146
48
|
/**
|
|
147
|
-
*
|
|
49
|
+
*
|
|
50
|
+
* @private
|
|
148
51
|
*/
|
|
149
52
|
private infoWebApp;
|
|
150
|
-
/**
|
|
151
|
-
* Stop file watcher
|
|
152
|
-
*/
|
|
153
|
-
private stopFileWatcher;
|
|
154
|
-
/**
|
|
155
|
-
* Shutdown server
|
|
156
|
-
*/
|
|
157
|
-
private shutdown;
|
|
158
|
-
/**
|
|
159
|
-
* Enable/disable watcher
|
|
160
|
-
*/
|
|
161
|
-
setWatcherEnabled(enabled: boolean): void;
|
|
162
|
-
/**
|
|
163
|
-
* Get watcher status
|
|
164
|
-
*/
|
|
165
|
-
getWatcherStatus(): {
|
|
166
|
-
enabled: boolean;
|
|
167
|
-
active: boolean;
|
|
168
|
-
};
|
|
169
|
-
/**
|
|
170
|
-
* Get server state information
|
|
171
|
-
*/
|
|
172
|
-
getServerState(): IServerStateInfo;
|
|
173
|
-
/**
|
|
174
|
-
* Simple method to get just the status
|
|
175
|
-
*/
|
|
176
|
-
getServerStatus(): TServerStatus;
|
|
177
|
-
/**
|
|
178
|
-
* Get server statistics for monitoring
|
|
179
|
-
*/
|
|
180
|
-
getServerStats(): {
|
|
181
|
-
status: TServerStatus;
|
|
182
|
-
uptime: string;
|
|
183
|
-
memory: {
|
|
184
|
-
rss: string;
|
|
185
|
-
heapTotal: string;
|
|
186
|
-
heapUsed: string;
|
|
187
|
-
external: string;
|
|
188
|
-
};
|
|
189
|
-
performance: {
|
|
190
|
-
cpuUsage: NodeJS.CpuUsage;
|
|
191
|
-
resourceUsage?: NodeJS.ResourceUsage;
|
|
192
|
-
};
|
|
193
|
-
};
|
|
194
|
-
/**
|
|
195
|
-
* Format bytes to human readable string
|
|
196
|
-
*/
|
|
197
|
-
private formatBytes;
|
|
198
|
-
/**
|
|
199
|
-
* Format uptime to human readable string
|
|
200
|
-
*/
|
|
201
|
-
private formatUptime;
|
|
202
|
-
/**
|
|
203
|
-
* Add watch directories
|
|
204
|
-
*/
|
|
205
|
-
addWatchDirectories(directories: string[]): void;
|
|
206
|
-
/**
|
|
207
|
-
* Clear file cache
|
|
208
|
-
*/
|
|
209
|
-
clearFileCache(): void;
|
|
210
|
-
/**
|
|
211
|
-
* Force reload configurations
|
|
212
|
-
*/
|
|
213
|
-
forceReloadConfig(): void;
|
|
214
|
-
/**
|
|
215
|
-
* Restart watcher
|
|
216
|
-
*/
|
|
217
|
-
restartWatcher(): void;
|
|
218
53
|
}
|
|
219
54
|
|
|
220
55
|
declare const envPath: string;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
+
import * as http from 'http';
|
|
1
2
|
import { Server } from 'http';
|
|
2
|
-
import { TDependency } from 'opticore-dependency-inject';
|
|
3
3
|
import { TFeatureRoutes } from 'opticore-router';
|
|
4
|
+
import { TDependency } from 'opticore-dependency-inject';
|
|
4
5
|
import { express } from 'opticore-express';
|
|
5
6
|
import { LoggerCore } from 'opticore-logger';
|
|
6
7
|
import { CorsOptions } from 'cors';
|
|
@@ -10,211 +11,45 @@ interface WebServerConstructorInterface {
|
|
|
10
11
|
loggerConfig: LoggerCore;
|
|
11
12
|
localLanguage: string;
|
|
12
13
|
environmentPath: any;
|
|
13
|
-
corsOriginOptions?: Partial<CorsOptions
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
type TServerStatus = "READY" | "RELOADING" | "BLOCKED" | "ERROR" | "STARTING" | "STOPPING";
|
|
17
|
-
|
|
18
|
-
interface IServerStateInfo {
|
|
19
|
-
status: TServerStatus;
|
|
20
|
-
isRunning: boolean;
|
|
21
|
-
host: string;
|
|
22
|
-
port: number;
|
|
23
|
-
language: string;
|
|
24
|
-
watcherEnabled: boolean;
|
|
25
|
-
watcherActive?: boolean;
|
|
26
|
-
routesCount: number;
|
|
27
|
-
dependenciesCount: number;
|
|
28
|
-
startTime?: Date;
|
|
29
|
-
currentTime?: Date;
|
|
30
|
-
uptime?: number;
|
|
31
|
-
memoryUsage?: NodeJS.MemoryUsage;
|
|
32
|
-
uptimeFormatted?: string;
|
|
33
|
-
pid?: any;
|
|
34
|
-
platform?: any;
|
|
35
|
-
nodeVersion?: any;
|
|
36
|
-
cwd?: any;
|
|
14
|
+
corsOriginOptions?: Partial<CorsOptions> | null;
|
|
37
15
|
}
|
|
38
16
|
|
|
39
17
|
declare class WebServerCore {
|
|
40
18
|
private serverUtility;
|
|
41
19
|
private expressApp;
|
|
42
|
-
private fileWatcher;
|
|
43
20
|
private readonly localLanguage;
|
|
44
21
|
private readonly loggerConfig;
|
|
45
22
|
private readonly routerExpressApp;
|
|
46
|
-
private readonly
|
|
23
|
+
private readonly getEnvironmentValue;
|
|
47
24
|
private readonly environmentPath;
|
|
48
25
|
private serverListenEvent;
|
|
49
|
-
private
|
|
50
|
-
private currentDependencies;
|
|
51
|
-
private server;
|
|
52
|
-
private errorEmitter;
|
|
53
|
-
private isWatcherEnabled;
|
|
54
|
-
private serverStatus;
|
|
55
|
-
private serverStartTime;
|
|
26
|
+
private dependenciesRegistered;
|
|
56
27
|
constructor(paramsConstructor: WebServerConstructorInterface);
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
private setupErrorHandling;
|
|
62
|
-
/**
|
|
63
|
-
* Setup server events
|
|
64
|
-
*/
|
|
65
|
-
private setupServerEvents;
|
|
66
|
-
/**
|
|
67
|
-
* Initialize file watcher
|
|
68
|
-
*/
|
|
69
|
-
private initializeFileWatcher;
|
|
70
|
-
/**
|
|
71
|
-
* Setup watcher events
|
|
72
|
-
*/
|
|
73
|
-
private setupWatcherEvents;
|
|
74
|
-
/**
|
|
75
|
-
* Handle file changes detected by watcher
|
|
76
|
-
*/
|
|
77
|
-
private handleFileChange;
|
|
78
|
-
/**
|
|
79
|
-
* Handle hot reload requested by watcher
|
|
80
|
-
*/
|
|
81
|
-
private handleHotReload;
|
|
82
|
-
/**
|
|
83
|
-
* Handle watcher errors
|
|
84
|
-
*/
|
|
85
|
-
private handleWatcherError;
|
|
86
|
-
/**
|
|
87
|
-
* Notify file change without action
|
|
88
|
-
*/
|
|
89
|
-
private notifyFileChange;
|
|
90
|
-
/**
|
|
91
|
-
* Reload environment configuration
|
|
92
|
-
*/
|
|
93
|
-
private reloadEnvironmentConfig;
|
|
94
|
-
/**
|
|
95
|
-
* Execute hot reload for environment files
|
|
96
|
-
*/
|
|
97
|
-
private executeHotReloadEnvironment;
|
|
98
|
-
/**
|
|
99
|
-
* Reload configuration files
|
|
100
|
-
*/
|
|
101
|
-
private reloadConfigurationFiles;
|
|
102
|
-
/**
|
|
103
|
-
* Execute hot reload for config files
|
|
104
|
-
*/
|
|
105
|
-
private executeHotReloadConfig;
|
|
106
|
-
/**
|
|
107
|
-
* Reload application routes
|
|
108
|
-
*/
|
|
109
|
-
private reloadApplicationRoutes;
|
|
110
|
-
/**
|
|
111
|
-
* Execute hot reload for routes
|
|
112
|
-
*/
|
|
113
|
-
private executeHotReloadRoutes;
|
|
114
|
-
/**
|
|
115
|
-
* Execute hot reload for dependencies
|
|
116
|
-
*/
|
|
117
|
-
private executeHotReloadDependencies;
|
|
28
|
+
registerDependencies(dependencies: TDependency[]): void;
|
|
29
|
+
onStartServer(routers: TFeatureRoutes[], databaseCallback: (env: any) => void, dependenciesProvider?: TDependency[]): Server<typeof http.IncomingMessage, typeof http.ServerResponse> | undefined;
|
|
30
|
+
onListeningOnServerEvent(serverWeb: Server): void;
|
|
31
|
+
onRequestOnServerEvent(serverWeb: Server): void;
|
|
118
32
|
/**
|
|
119
|
-
*
|
|
33
|
+
*
|
|
34
|
+
* @private
|
|
120
35
|
*/
|
|
121
|
-
private
|
|
36
|
+
private loadTranslationFiles;
|
|
122
37
|
/**
|
|
123
|
-
*
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
/**
|
|
127
|
-
* Reload router for specific file
|
|
128
|
-
*/
|
|
129
|
-
private reloadRouterForFile;
|
|
130
|
-
/**
|
|
131
|
-
* Reload configurations
|
|
132
|
-
*/
|
|
133
|
-
private reloadConfigurations;
|
|
134
|
-
/**
|
|
135
|
-
* Reload dependencies
|
|
136
|
-
*/
|
|
137
|
-
private reloadDependencies;
|
|
138
|
-
/**
|
|
139
|
-
* Register routes
|
|
38
|
+
*
|
|
39
|
+
* @param allFeatureRoutes
|
|
40
|
+
* @private
|
|
140
41
|
*/
|
|
141
42
|
private registerRoutes;
|
|
142
43
|
/**
|
|
143
|
-
*
|
|
44
|
+
*
|
|
45
|
+
* @private
|
|
144
46
|
*/
|
|
145
|
-
private
|
|
47
|
+
private stackTraceErrorHandling;
|
|
146
48
|
/**
|
|
147
|
-
*
|
|
49
|
+
*
|
|
50
|
+
* @private
|
|
148
51
|
*/
|
|
149
52
|
private infoWebApp;
|
|
150
|
-
/**
|
|
151
|
-
* Stop file watcher
|
|
152
|
-
*/
|
|
153
|
-
private stopFileWatcher;
|
|
154
|
-
/**
|
|
155
|
-
* Shutdown server
|
|
156
|
-
*/
|
|
157
|
-
private shutdown;
|
|
158
|
-
/**
|
|
159
|
-
* Enable/disable watcher
|
|
160
|
-
*/
|
|
161
|
-
setWatcherEnabled(enabled: boolean): void;
|
|
162
|
-
/**
|
|
163
|
-
* Get watcher status
|
|
164
|
-
*/
|
|
165
|
-
getWatcherStatus(): {
|
|
166
|
-
enabled: boolean;
|
|
167
|
-
active: boolean;
|
|
168
|
-
};
|
|
169
|
-
/**
|
|
170
|
-
* Get server state information
|
|
171
|
-
*/
|
|
172
|
-
getServerState(): IServerStateInfo;
|
|
173
|
-
/**
|
|
174
|
-
* Simple method to get just the status
|
|
175
|
-
*/
|
|
176
|
-
getServerStatus(): TServerStatus;
|
|
177
|
-
/**
|
|
178
|
-
* Get server statistics for monitoring
|
|
179
|
-
*/
|
|
180
|
-
getServerStats(): {
|
|
181
|
-
status: TServerStatus;
|
|
182
|
-
uptime: string;
|
|
183
|
-
memory: {
|
|
184
|
-
rss: string;
|
|
185
|
-
heapTotal: string;
|
|
186
|
-
heapUsed: string;
|
|
187
|
-
external: string;
|
|
188
|
-
};
|
|
189
|
-
performance: {
|
|
190
|
-
cpuUsage: NodeJS.CpuUsage;
|
|
191
|
-
resourceUsage?: NodeJS.ResourceUsage;
|
|
192
|
-
};
|
|
193
|
-
};
|
|
194
|
-
/**
|
|
195
|
-
* Format bytes to human readable string
|
|
196
|
-
*/
|
|
197
|
-
private formatBytes;
|
|
198
|
-
/**
|
|
199
|
-
* Format uptime to human readable string
|
|
200
|
-
*/
|
|
201
|
-
private formatUptime;
|
|
202
|
-
/**
|
|
203
|
-
* Add watch directories
|
|
204
|
-
*/
|
|
205
|
-
addWatchDirectories(directories: string[]): void;
|
|
206
|
-
/**
|
|
207
|
-
* Clear file cache
|
|
208
|
-
*/
|
|
209
|
-
clearFileCache(): void;
|
|
210
|
-
/**
|
|
211
|
-
* Force reload configurations
|
|
212
|
-
*/
|
|
213
|
-
forceReloadConfig(): void;
|
|
214
|
-
/**
|
|
215
|
-
* Restart watcher
|
|
216
|
-
*/
|
|
217
|
-
restartWatcher(): void;
|
|
218
53
|
}
|
|
219
54
|
|
|
220
55
|
declare const envPath: string;
|