oneuptime/CommonServer/API/StatusAPI.ts

30 lines
773 B
TypeScript
Raw Normal View History

2022-04-18 14:38:26 +00:00
import Express, {
ExpressRequest,
ExpressResponse,
ExpressRouter,
} from '../Utils/Express';
2022-05-24 17:05:47 +00:00
import LocalCache from '../Infrastructure/LocalCache';
2022-04-08 12:26:02 +00:00
2022-04-18 14:38:26 +00:00
const router: ExpressRouter = Express.getRouter();
2022-04-08 12:26:02 +00:00
2022-12-30 13:03:01 +00:00
router.get('/app-name', (_req: ExpressRequest, res: ExpressResponse) => {
2022-05-25 18:24:43 +00:00
res.send({ app: LocalCache.getString('app', 'name') });
2022-05-24 16:46:21 +00:00
});
2022-04-15 22:14:01 +00:00
// General status
2022-04-08 12:26:02 +00:00
router.get('/status', (_req: ExpressRequest, res: ExpressResponse) => {
2022-12-29 17:14:29 +00:00
res.send({ status: 'ok' });
2022-04-08 12:26:02 +00:00
});
2022-04-15 22:14:01 +00:00
//Healthy probe
2022-04-08 12:26:02 +00:00
router.get('/status/healthy', (_req: ExpressRequest, res: ExpressResponse) => {
res.send({ status: 'healthy' });
});
2022-04-15 22:14:01 +00:00
//Liveness probe
2022-04-08 12:26:02 +00:00
router.get('/status/live', (_req: ExpressRequest, res: ExpressResponse) => {
res.send({ status: 'live' });
});
export default router;