Files
whale-town-end/src/app.service.ts
moyin bb796a2469 refactor:项目架构重构和命名规范化
- 统一文件命名为snake_case格式(kebab-case  snake_case)
- 重构zulip模块为zulip_core,明确Core层职责
- 重构user-mgmt模块为user_mgmt,统一命名规范
- 调整模块依赖关系,优化架构分层
- 删除过时的文件和目录结构
- 更新相关文档和配置文件

本次重构涉及大量文件重命名和模块重组,
旨在建立更清晰的项目架构和统一的命名规范。
2026-01-08 00:14:14 +08:00

53 lines
1.3 KiB
TypeScript

import { Injectable } from '@nestjs/common';
import { ConfigService } from '@nestjs/config';
import { AppStatusResponseDto } from './business/shared';
/**
* 应用服务类
*
* 功能描述:
* - 提供应用基础服务
* - 返回应用运行状态信息
*
* @author angjustinl
* @version 1.0.0
* @since 2025-12-17
*/
@Injectable()
export class AppService {
private readonly startTime: number;
constructor(private readonly configService: ConfigService) {
this.startTime = Date.now();
}
/**
* 获取应用状态
*
* @returns 应用状态信息
*/
getStatus(): AppStatusResponseDto {
const isDatabaseConfigured = this.isDatabaseConfigured();
return {
service: 'Pixel Game Server',
version: '1.1.1',
status: 'running',
timestamp: new Date().toISOString(),
uptime: Math.floor((Date.now() - this.startTime) / 1000),
environment: this.configService.get<string>('NODE_ENV', 'development'),
storageMode: isDatabaseConfigured ? 'database' : 'memory'
};
}
/**
* 检查数据库配置是否完整
*
* @returns 是否配置了数据库
*/
private isDatabaseConfigured(): boolean {
const requiredEnvVars = ['DB_HOST', 'DB_PORT', 'DB_USERNAME', 'DB_PASSWORD', 'DB_NAME'];
return requiredEnvVars.every(varName => this.configService.get<string>(varName));
}
}