api-server/src/modules/auth/dto/auth-response.dto.ts
wangdl b9e6055400
All checks were successful
Deploy API Server / build-and-deploy (push) Successful in 41s
fix: H0-01 彻底阻断生产环境 mock + 结构化错误码 + iOS Auth 合同文档
- apple-auth.service.ts: verifyIdentityToken 增加 NODE_ENV 检查,
  生产环境缺 APPLE_BUNDLE_ID 时运行时返回 401,不再走 mock
- 新增 CAPIErrorCode 语义错误码体系 (src/common/errors/)
- 新增 CapiException 携带 errorCode 的 HttpException 子类
- GlobalExceptionFilter 响应自动包含 errorCode 字段
- AuthService/JwtAuthGuard/AppleAuthService 全部改用 CapiException
- 新增 LoginResponseDto/RefreshResponseDto/LogoutResponseDto/UserDto
- Auth controller Swagger 添加 type 参数
- 新增 docs/ios-auth-api-contract.md

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-27 21:03:15 +08:00

51 lines
1.2 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import { ApiProperty } from '@nestjs/swagger';
export class UserDto {
@ApiProperty({ example: 'clx...' })
id: string;
@ApiProperty({ example: 'user@example.com', nullable: true })
email: string | null;
@ApiProperty({ example: '张三', nullable: true })
nickname: string | null;
@ApiProperty({ example: null, nullable: true })
avatarUrl: string | null;
@ApiProperty({ example: 'user' })
role: string;
@ApiProperty({ example: 'active' })
status: string;
@ApiProperty({ example: false })
onboardingCompleted: boolean;
}
export class AuthTokensDto {
@ApiProperty({ description: 'JWT access token有效期 1h', example: 'eyJhbG...' })
accessToken: string;
@ApiProperty({ description: '96 位十六进制 refresh token一次性轮换', example: 'a1b2c3...' })
refreshToken: string;
}
export class LoginResponseDto extends AuthTokensDto {
@ApiProperty({ type: UserDto })
user: UserDto;
}
export class RefreshResponseDto extends AuthTokensDto {
@ApiProperty({ type: UserDto })
user: UserDto;
}
export class LogoutResponseDto {
@ApiProperty({ example: true })
success: boolean;
@ApiProperty({ example: '已退出登录' })
message: string;
}