opticore-webapp 1.0.66 → 1.0.68

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.d.cts CHANGED
@@ -1,104 +1,224 @@
1
- import { CorsOptions } from 'cors';
2
1
  import { Server } from 'http';
2
+ import { TDependency } from 'opticore-dependency-inject';
3
+ import { TFeatureRoutes } from 'opticore-router';
3
4
  import { express } from 'opticore-express';
4
5
  import { LoggerCore } from 'opticore-logger';
5
- import { TDependencyKey, TDependency } from 'opticore-dependency-inject';
6
+ import { CorsOptions } from 'cors';
6
7
 
7
- interface IRouteDefinition {
8
- path: string;
9
- handler: express.Router;
8
+ interface WebServerConstructorInterface {
9
+ app: express.Application;
10
+ loggerConfig: LoggerCore;
11
+ localLanguage: string;
12
+ environmentPath: any;
13
+ corsOriginOptions?: Partial<CorsOptions>;
10
14
  }
11
15
 
12
- type TFeatureRoutes = {
13
- featureName?: string;
14
- featureRoute: IRouteDefinition[];
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;
37
+ }
16
38
 
17
39
  declare class WebServerCore {
18
40
  private serverUtility;
19
41
  private expressApp;
42
+ private fileWatcher;
20
43
  private readonly localLanguage;
21
44
  private readonly loggerConfig;
22
45
  private readonly routerExpressApp;
23
46
  private readonly getEnvironment;
24
47
  private readonly environmentPath;
25
48
  private serverListenEvent;
26
- private isHotReloading;
27
49
  private currentRoutes;
28
50
  private currentDependencies;
29
- constructor(app: express.Application, loggerConfig: LoggerCore, localLanguage: string, environmentPath: any, corsOriginOptions?: Partial<CorsOptions>);
51
+ private server;
52
+ private errorEmitter;
53
+ private isWatcherEnabled;
54
+ private serverStatus;
55
+ private serverStartTime;
56
+ constructor(paramsConstructor: WebServerConstructorInterface);
57
+ onStartServer(routers: TFeatureRoutes[], databaseCallback?: (env: any) => void, dependenciesProvider?: TDependency[]): Server | undefined;
30
58
  /**
31
- *
32
- * @param dependencies
59
+ * Error handling configuration
33
60
  */
34
- registerDependencies(dependencies: Map<TDependencyKey, any>): void;
61
+ private setupErrorHandling;
35
62
  /**
36
- *
37
- * @param routers
38
- * @param databaseCallback
39
- * @param dependenciesProvider
63
+ * Setup server events
40
64
  */
41
- onStartServer(routers: TFeatureRoutes[], databaseCallback: (env: any) => void, dependenciesProvider?: TDependency[]): any;
65
+ private setupServerEvents;
42
66
  /**
43
- *
44
- * @param serverWeb
67
+ * Initialize file watcher
45
68
  */
46
- onListeningOnServerEvent(serverWeb: Server): void;
69
+ private initializeFileWatcher;
47
70
  /**
48
- *
49
- * @param serverWeb
71
+ * Setup watcher events
50
72
  */
51
- onRequestOnServerEvent(serverWeb: Server): void;
73
+ private setupWatcherEvents;
52
74
  /**
53
- *
54
- * @param allFeatureRoutes
55
- * @private
75
+ * Handle file changes detected by watcher
56
76
  */
57
- private registerRoutes;
77
+ private handleFileChange;
58
78
  /**
59
- *
60
- * @param localLanguage
61
- * @private
79
+ * Handle hot reload requested by watcher
62
80
  */
63
- private stackTraceErrorHandling;
81
+ private handleHotReload;
64
82
  /**
65
- *
66
- * @private
83
+ * Handle watcher errors
67
84
  */
68
- private infoWebApp;
69
- private setupSignalHandlers;
85
+ private handleWatcherError;
70
86
  /**
71
- * Logique de rechargement à chaud
87
+ * Notify file change without action
72
88
  */
73
- private handleHotReload;
89
+ private notifyFileChange;
74
90
  /**
75
- * Clear server module cache
91
+ * Reload environment configuration
76
92
  */
77
- private clearServerCache;
93
+ private reloadEnvironmentConfig;
78
94
  /**
79
- * Recharger les configurations
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;
118
+ /**
119
+ * Notify environment reload
120
+ */
121
+ private notifyEnvironmentReload;
122
+ /**
123
+ * Reload specific route
124
+ */
125
+ private reloadSpecificRoute;
126
+ /**
127
+ * Reload router for specific file
128
+ */
129
+ private reloadRouterForFile;
130
+ /**
131
+ * Reload configurations
80
132
  */
81
133
  private reloadConfigurations;
82
134
  /**
83
- * Recharger les dépendances
135
+ * Reload dependencies
84
136
  */
85
137
  private reloadDependencies;
86
138
  /**
87
- * Recharger les routes
139
+ * Register routes
140
+ */
141
+ private registerRoutes;
142
+ /**
143
+ * Parse transform error
88
144
  */
89
- private reloadRoutes;
145
+ private parseTransformError;
90
146
  /**
91
- * Recharger les services
147
+ * Display server info
92
148
  */
93
- private reloadServices;
149
+ 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;
94
218
  }
95
219
 
96
220
  declare const envPath: string;
97
221
 
98
- type TFeatureRouteDefinition = {
99
- featureRoute: IRouteDefinition[];
100
- };
101
-
102
- type KernelModuleType = [TFeatureRouteDefinition[], () => void];
222
+ type KernelModuleType = [any[], () => void];
103
223
 
104
- export { type IRouteDefinition, type KernelModuleType, type TFeatureRoutes, WebServerCore as WebServer, envPath };
224
+ export { type KernelModuleType, WebServerCore as WebServer, envPath };
package/dist/index.d.ts CHANGED
@@ -1,104 +1,224 @@
1
- import { CorsOptions } from 'cors';
2
1
  import { Server } from 'http';
2
+ import { TDependency } from 'opticore-dependency-inject';
3
+ import { TFeatureRoutes } from 'opticore-router';
3
4
  import { express } from 'opticore-express';
4
5
  import { LoggerCore } from 'opticore-logger';
5
- import { TDependencyKey, TDependency } from 'opticore-dependency-inject';
6
+ import { CorsOptions } from 'cors';
6
7
 
7
- interface IRouteDefinition {
8
- path: string;
9
- handler: express.Router;
8
+ interface WebServerConstructorInterface {
9
+ app: express.Application;
10
+ loggerConfig: LoggerCore;
11
+ localLanguage: string;
12
+ environmentPath: any;
13
+ corsOriginOptions?: Partial<CorsOptions>;
10
14
  }
11
15
 
12
- type TFeatureRoutes = {
13
- featureName?: string;
14
- featureRoute: IRouteDefinition[];
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;
37
+ }
16
38
 
17
39
  declare class WebServerCore {
18
40
  private serverUtility;
19
41
  private expressApp;
42
+ private fileWatcher;
20
43
  private readonly localLanguage;
21
44
  private readonly loggerConfig;
22
45
  private readonly routerExpressApp;
23
46
  private readonly getEnvironment;
24
47
  private readonly environmentPath;
25
48
  private serverListenEvent;
26
- private isHotReloading;
27
49
  private currentRoutes;
28
50
  private currentDependencies;
29
- constructor(app: express.Application, loggerConfig: LoggerCore, localLanguage: string, environmentPath: any, corsOriginOptions?: Partial<CorsOptions>);
51
+ private server;
52
+ private errorEmitter;
53
+ private isWatcherEnabled;
54
+ private serverStatus;
55
+ private serverStartTime;
56
+ constructor(paramsConstructor: WebServerConstructorInterface);
57
+ onStartServer(routers: TFeatureRoutes[], databaseCallback?: (env: any) => void, dependenciesProvider?: TDependency[]): Server | undefined;
30
58
  /**
31
- *
32
- * @param dependencies
59
+ * Error handling configuration
33
60
  */
34
- registerDependencies(dependencies: Map<TDependencyKey, any>): void;
61
+ private setupErrorHandling;
35
62
  /**
36
- *
37
- * @param routers
38
- * @param databaseCallback
39
- * @param dependenciesProvider
63
+ * Setup server events
40
64
  */
41
- onStartServer(routers: TFeatureRoutes[], databaseCallback: (env: any) => void, dependenciesProvider?: TDependency[]): any;
65
+ private setupServerEvents;
42
66
  /**
43
- *
44
- * @param serverWeb
67
+ * Initialize file watcher
45
68
  */
46
- onListeningOnServerEvent(serverWeb: Server): void;
69
+ private initializeFileWatcher;
47
70
  /**
48
- *
49
- * @param serverWeb
71
+ * Setup watcher events
50
72
  */
51
- onRequestOnServerEvent(serverWeb: Server): void;
73
+ private setupWatcherEvents;
52
74
  /**
53
- *
54
- * @param allFeatureRoutes
55
- * @private
75
+ * Handle file changes detected by watcher
56
76
  */
57
- private registerRoutes;
77
+ private handleFileChange;
58
78
  /**
59
- *
60
- * @param localLanguage
61
- * @private
79
+ * Handle hot reload requested by watcher
62
80
  */
63
- private stackTraceErrorHandling;
81
+ private handleHotReload;
64
82
  /**
65
- *
66
- * @private
83
+ * Handle watcher errors
67
84
  */
68
- private infoWebApp;
69
- private setupSignalHandlers;
85
+ private handleWatcherError;
70
86
  /**
71
- * Logique de rechargement à chaud
87
+ * Notify file change without action
72
88
  */
73
- private handleHotReload;
89
+ private notifyFileChange;
74
90
  /**
75
- * Clear server module cache
91
+ * Reload environment configuration
76
92
  */
77
- private clearServerCache;
93
+ private reloadEnvironmentConfig;
78
94
  /**
79
- * Recharger les configurations
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;
118
+ /**
119
+ * Notify environment reload
120
+ */
121
+ private notifyEnvironmentReload;
122
+ /**
123
+ * Reload specific route
124
+ */
125
+ private reloadSpecificRoute;
126
+ /**
127
+ * Reload router for specific file
128
+ */
129
+ private reloadRouterForFile;
130
+ /**
131
+ * Reload configurations
80
132
  */
81
133
  private reloadConfigurations;
82
134
  /**
83
- * Recharger les dépendances
135
+ * Reload dependencies
84
136
  */
85
137
  private reloadDependencies;
86
138
  /**
87
- * Recharger les routes
139
+ * Register routes
140
+ */
141
+ private registerRoutes;
142
+ /**
143
+ * Parse transform error
88
144
  */
89
- private reloadRoutes;
145
+ private parseTransformError;
90
146
  /**
91
- * Recharger les services
147
+ * Display server info
92
148
  */
93
- private reloadServices;
149
+ 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;
94
218
  }
95
219
 
96
220
  declare const envPath: string;
97
221
 
98
- type TFeatureRouteDefinition = {
99
- featureRoute: IRouteDefinition[];
100
- };
101
-
102
- type KernelModuleType = [TFeatureRouteDefinition[], () => void];
222
+ type KernelModuleType = [any[], () => void];
103
223
 
104
- export { type IRouteDefinition, type KernelModuleType, type TFeatureRoutes, WebServerCore as WebServer, envPath };
224
+ export { type KernelModuleType, WebServerCore as WebServer, envPath };