* 新增完整的 API 状态码文档,并对测试模式进行特殊处理(`206 Partial Content`) * 重组 DTO 结构,引入 `app.dto.ts` 与 `error_response.dto.ts`,以实现统一、规范的响应格式 * 重构登录相关 DTO,优化命名与结构,提升可维护性 * 实现基于内存的用户服务(`users_memory.service.ts`),用于开发与测试环境 * 更新邮件服务,增强验证码生成逻辑,并支持测试模式自动识别 * 增强登录控制器与服务层的错误处理能力,统一响应行为 * 优化核心登录服务,强化参数校验并集成邮箱验证流程 * 新增 `@types/express` 依赖,提升 TypeScript 类型支持与开发体验 * 改进 `main.ts`,优化应用初始化流程与配置管理 * 在所有服务中统一错误处理机制,采用标准化的错误响应格式 * 实现测试模式(`206`)与生产环境邮件发送(`200`)之间的无缝切换
72 lines
1.3 KiB
TypeScript
72 lines
1.3 KiB
TypeScript
/**
|
|
* 应用状态响应 DTO
|
|
*
|
|
* 功能描述:
|
|
* - 定义应用状态接口的响应格式
|
|
* - 提供 Swagger 文档生成支持
|
|
*
|
|
* @author angjustinl
|
|
* @version 1.0.0
|
|
* @since 2025-12-17
|
|
*/
|
|
|
|
import { ApiProperty } from '@nestjs/swagger';
|
|
|
|
/**
|
|
* 应用状态响应 DTO
|
|
*/
|
|
export class AppStatusResponseDto {
|
|
@ApiProperty({
|
|
description: '服务名称',
|
|
example: 'Pixel Game Server',
|
|
type: String
|
|
})
|
|
service: string;
|
|
|
|
@ApiProperty({
|
|
description: '服务版本',
|
|
example: '1.0.0',
|
|
type: String
|
|
})
|
|
version: string;
|
|
|
|
@ApiProperty({
|
|
description: '运行状态',
|
|
example: 'running',
|
|
enum: ['running', 'starting', 'stopping', 'error'],
|
|
type: String
|
|
})
|
|
status: string;
|
|
|
|
@ApiProperty({
|
|
description: '当前时间戳',
|
|
example: '2025-12-17T15:00:00.000Z',
|
|
type: String,
|
|
format: 'date-time'
|
|
})
|
|
timestamp: string;
|
|
|
|
@ApiProperty({
|
|
description: '运行时间(秒)',
|
|
example: 3600,
|
|
type: Number,
|
|
minimum: 0
|
|
})
|
|
uptime: number;
|
|
|
|
@ApiProperty({
|
|
description: '运行环境',
|
|
example: 'development',
|
|
enum: ['development', 'production', 'test'],
|
|
type: String
|
|
})
|
|
environment: string;
|
|
|
|
@ApiProperty({
|
|
description: '存储模式',
|
|
example: 'memory',
|
|
enum: ['database', 'memory'],
|
|
type: String
|
|
})
|
|
storage_mode: 'database' | 'memory';
|
|
} |