Add README and initial project structure for WebSocket chat application
* Created README.md for project overview and setup instructions. * Updated App component to use selector for todo items. * Enhanced TodoItemComponent styling and structure. * Introduced new Redux selectors for better state management. * Added initial configuration files for RequireJS and Bun. * Established project structure for WebSocket chat application with server and frontend components. * Included necessary dependencies and configurations for TypeScript and Vite.
This commit is contained in:
@@ -0,0 +1,72 @@
|
||||
import type {Request, Response} from 'express';
|
||||
import type IRoute from '../net/http/IRoutes';
|
||||
import IHealthCheck from './IHealthCheck';
|
||||
|
||||
export default class HealthCheckRoute implements IRoute {
|
||||
private readonly _healthCheck: IHealthCheck;
|
||||
|
||||
constructor(healthCheck: IHealthCheck) {
|
||||
this._healthCheck = healthCheck;
|
||||
}
|
||||
|
||||
public getGETRoutes() {
|
||||
console.log('[HealthCheckRoute] getGETRoutes called');
|
||||
const routes = {
|
||||
'/ok.html': (req, res) => this.externalReadiness.call(this, req, res),
|
||||
'/ping': (req, res) => this.ping.call(this, req, res)
|
||||
};
|
||||
console.log('[HealthCheckRoute] returning routes:', Object.keys(routes));
|
||||
return routes;
|
||||
}
|
||||
|
||||
public getPOSTRoutes() {
|
||||
return {};
|
||||
}
|
||||
|
||||
public getPUTRoutes() {
|
||||
return {};
|
||||
}
|
||||
|
||||
public getPATCHRoutes() {
|
||||
return {};
|
||||
}
|
||||
|
||||
public getDELETERoutes() {
|
||||
return {};
|
||||
}
|
||||
|
||||
private externalReadiness(_req: Request, res: Response) {
|
||||
console.log('[HealthCheckRoute] External readiness');
|
||||
res.setHeader('Cache-Control', 'public, max-age=0, no-cache, no-store');
|
||||
|
||||
try {
|
||||
const result = this._healthCheck.checkHealth();
|
||||
|
||||
if (!result || !result.status) {
|
||||
return res.status(500).end();
|
||||
}
|
||||
|
||||
switch (result.status) {
|
||||
case 'ok':
|
||||
case 'draining':
|
||||
case 'draining2':
|
||||
case 'disabled':
|
||||
return res.status(200).json(result);
|
||||
case 'starting':
|
||||
case 'drained':
|
||||
case 'stopped':
|
||||
return res.status(503).json(result);
|
||||
default:
|
||||
return res.status(500).json(result);
|
||||
}
|
||||
} catch {
|
||||
return res.status(500).end();
|
||||
}
|
||||
}
|
||||
|
||||
private ping(_req: Request, res: Response) {
|
||||
console.log('[HealthCheckRoute] Ping handler called from [%s]', _req.ip);
|
||||
|
||||
res.status(200).send({status: 'pong'}).end();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user