- 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
61 lines
1.7 KiB
TypeScript
61 lines
1.7 KiB
TypeScript
import type {HealthCheck} from '../health/HealthCheck.js';
|
|
import type {RoutePath, RouteHandler} from '../net/http/HttpRouteManger.js';
|
|
import type {IApiRoute} from './IApiRoute';
|
|
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 _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> {
|
|
return this._getRoutes;
|
|
}
|
|
|
|
public getPOSTRoutes(): Record<RoutePath, RouteHandler> {
|
|
return this._postRoutes;
|
|
}
|
|
|
|
public getPUTRoutes(): Record<RoutePath, RouteHandler> {
|
|
return this._putRoutes;
|
|
}
|
|
|
|
public getDELETERoutes(): Record<RoutePath, RouteHandler> {
|
|
return this._deleteRoutes;
|
|
}
|
|
|
|
private setupGETRoutes(): Record<RoutePath, RouteHandler> {
|
|
return {
|
|
'/_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);
|
|
}
|
|
}
|