feat: multi-module iteration

This commit is contained in:
2026-08-04 21:38:49 +08:00
parent 9d96c73246
commit 71f508e02b
1366 changed files with 202004 additions and 0 deletions
@@ -0,0 +1,35 @@
import { Controller, Get } from '@nestjs/common';
import { PrismaService } from '../../common/prisma/prisma.module';
import { RedisService } from '../../common/redis/redis.service';
@Controller('health')
export class HealthController {
constructor(
private readonly prisma: PrismaService,
private readonly redis: RedisService,
) {}
@Get()
async check() {
let db: 'ok' | 'error' = 'ok';
let redis: 'ok' | 'error' = 'ok';
try {
await this.prisma.$queryRaw`SELECT 1`;
} catch {
db = 'error';
}
try {
const pong = await this.redis.client.ping();
if (pong !== 'PONG') redis = 'error';
} catch {
redis = 'error';
}
const status = db === 'ok' && redis === 'ok' ? 'ok' : 'degraded';
return {
status,
service: 'dukang-api',
version: 'prev1',
checks: { db, redis },
};
}
}
@@ -0,0 +1,6 @@
import { Module } from '@nestjs/common';
import { HealthController } from './health.controller';
/** Prisma / Redis 已为 GlobalHealth 直接注入探活 */
@Module({ controllers: [HealthController] })
export class HealthModule {}