diff --git a/backend/services/identity-service/scripts/health-check.sh b/backend/services/identity-service/scripts/health-check.sh index 976d2015..633eec02 100755 --- a/backend/services/identity-service/scripts/health-check.sh +++ b/backend/services/identity-service/scripts/health-check.sh @@ -51,7 +51,7 @@ check_service "Identity Service" "curl -f http://localhost:3000/health" "npm run # 检查 Swagger 文档 echo -e "${YELLOW}=== API 文档 ===${NC}" -check_service "Swagger UI" "curl -f http://localhost:3000/api" "等待 Identity Service 启动" +check_service "Swagger UI" "curl -f http://localhost:3000/api/docs" "等待 Identity Service 启动" echo "" echo -e "${YELLOW}======================================${NC}" diff --git a/backend/services/identity-service/src/api/controllers/health.controller.ts b/backend/services/identity-service/src/api/controllers/health.controller.ts new file mode 100644 index 00000000..49443b6f --- /dev/null +++ b/backend/services/identity-service/src/api/controllers/health.controller.ts @@ -0,0 +1,18 @@ +import { Controller, Get } from '@nestjs/common'; +import { ApiTags, ApiOperation } from '@nestjs/swagger'; +import { Public } from '@/shared/decorators/public.decorator'; + +@ApiTags('健康检查') +@Controller() +export class HealthController { + @Public() + @Get('health') + @ApiOperation({ summary: '健康检查端点' }) + health() { + return { + status: 'ok', + timestamp: new Date().toISOString(), + service: 'identity-service', + }; + } +} diff --git a/backend/services/identity-service/src/app.module.ts b/backend/services/identity-service/src/app.module.ts index 9f274d2e..91b72ddc 100644 --- a/backend/services/identity-service/src/app.module.ts +++ b/backend/services/identity-service/src/app.module.ts @@ -8,6 +8,7 @@ import { appConfig, databaseConfig, jwtConfig, redisConfig, kafkaConfig, smsConf // Controllers import { UserAccountController } from '@/api/controllers/user-account.controller'; +import { HealthController } from '@/api/controllers/health.controller'; // Application Services import { UserApplicationService } from '@/application/services/user-application.service'; @@ -67,7 +68,7 @@ export class ApplicationModule {} // ============ API Module ============ @Module({ imports: [ApplicationModule], - controllers: [UserAccountController], + controllers: [HealthController, UserAccountController], }) export class ApiModule {}