Implement configuration management and dependency injection framework
- Added ConfigurationReader for loading dependency definitions - Introduced FileConfigurationLoader for file-based configuration loading - Created IDependencyManager and IDependencyProvider interfaces for managing dependencies - Implemented DependencyProvider for providing instances based on lifecycle - Added Default class for logging level configuration - Enhanced HealthCheckApi with improved route setup and health check handling
This commit is contained in:
@@ -5,14 +5,17 @@ import type express from 'express';
|
||||
|
||||
export class HealthCheckApi implements IApiRoute {
|
||||
private readonly _getRoutes: Record<string, RouteHandler>;
|
||||
private readonly _postRoutes: Record<string, RouteHandler> = {};
|
||||
private readonly _putRoutes: Record<string, RouteHandler> = {};
|
||||
private readonly _deleteRoutes: Record<string, RouteHandler> = {};
|
||||
private readonly _postRoutes: Record<string, RouteHandler>;
|
||||
private readonly _putRoutes: Record<string, RouteHandler>;
|
||||
private readonly _deleteRoutes: Record<string, RouteHandler>;
|
||||
private readonly _healthCheck: HealthCheck;
|
||||
|
||||
constructor(healthCheck: HealthCheck) {
|
||||
this._healthCheck = healthCheck;
|
||||
this._getRoutes = this.setupGETRoutes();
|
||||
this._postRoutes = this.setupPOSTRoutes();
|
||||
this._putRoutes = this.setupPUTRoutes();
|
||||
this._deleteRoutes = this.setupDELETERoutes();
|
||||
}
|
||||
|
||||
public getGETRoutes(): Record<RoutePath, RouteHandler> {
|
||||
@@ -33,11 +36,25 @@ export class HealthCheckApi implements IApiRoute {
|
||||
|
||||
private setupGETRoutes(): Record<RoutePath, RouteHandler> {
|
||||
return {
|
||||
'/_health': (req: express.Request, res: express.Response) => {
|
||||
const health = this._healthCheck.getHealth();
|
||||
|
||||
res.send(health);
|
||||
}
|
||||
'/_health': this.getHealth.bind(this)
|
||||
};
|
||||
}
|
||||
|
||||
private setupPOSTRoutes(): Record<RoutePath, RouteHandler> {
|
||||
return {};
|
||||
}
|
||||
|
||||
private setupPUTRoutes(): Record<RoutePath, RouteHandler> {
|
||||
return {};
|
||||
}
|
||||
|
||||
private setupDELETERoutes(): Record<RoutePath, RouteHandler> {
|
||||
return {};
|
||||
}
|
||||
|
||||
private getHealth(req: express.Request, res: express.Response): void {
|
||||
const health = this._healthCheck.getHealth();
|
||||
|
||||
res.send(health);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user