mirror of
https://github.com/whyour/qinglong.git
synced 2026-12-01 01:39:52 +08:00
* fix(security): close anonymous notification setup and mask server errors * fix: hide internal errors in default deployment * fix: route HTTP errors through application logger * test: mock logger in API fallback regression * fix: avoid sensitive SQL details in HTTP error logs
27 lines
733 B
TypeScript
27 lines
733 B
TypeScript
import { Router } from 'express';
|
|
import Logger from '../loaders/logger';
|
|
import { HealthService } from '../services/health';
|
|
import Container from 'typedi';
|
|
const route = Router();
|
|
|
|
export default (app: Router) => {
|
|
app.use('/', route);
|
|
|
|
route.get('/health', async (req, res) => {
|
|
try {
|
|
const healthService = Container.get(HealthService);
|
|
const health = await healthService.check();
|
|
res.status(health.status === 'ok' ? 200 : 503).send({
|
|
code: health.status === 'ok' ? 200 : 503,
|
|
data: health,
|
|
});
|
|
} catch (err: any) {
|
|
Logger.error('Health check failed:', err);
|
|
res.status(500).send({
|
|
code: 500,
|
|
message: 'Health check failed',
|
|
});
|
|
}
|
|
});
|
|
};
|