import { RouterOptions } from 'express'; import { HttpStatusException } from '../../../common/lib/http-status.exception'; import { ControllerPool } from '../ctrl/controller-pool.interface'; import { WebHandler } from './web-handler.base'; export class ServicesAPIHandler extends WebHandler { constructor(protected ctrlPool: ControllerPool, options?: RouterOptions) { super(ctrlPool, options); this.router.use(this.avoidCache); this.router.get('/:serverID', async (req, res, next) => { try { const serverID = Number(req.params.serverID); if (Number.isNaN(serverID)) { throw new HttpStatusException(`Not a valid server id: ${req.params.serverID}`, 400); } const services = await this.ctrlPool.db.getHealthCheckConfigs(serverID); res.send(services); } catch (err) { next(err); } }); } }