From 852b56d00c86d2fae460c6660d11ca5596759aff Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=9C=A4=EC=A0=95=EB=AF=BC?= Date: Mon, 20 Jul 2026 16:40:29 +0900 Subject: [PATCH] Tolerate missing createdAt in user profile response MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - serverTimestamp 미해석 문서나 레거시 문서에서 toIso가 던져 GET /user가 500이 되는 경로 제거 - UserProfileDto.createdAt을 optional로 두고 toIsoOrUndefined 사용 — 값이 없으면 키를 생략한다 - 스프레드로 조립하던 기존 동작(키 생략)과 동일하게 맞춤 --- src/services/userService.ts | 4 ++-- src/types/dto/userDto.ts | 10 ++++++++-- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/src/services/userService.ts b/src/services/userService.ts index 023d7bb..17e6ba2 100644 --- a/src/services/userService.ts +++ b/src/services/userService.ts @@ -29,7 +29,7 @@ import { type Provider, type User, } from "../types/panit"; -import { toIso } from "../types/dto/iso"; +import { toIso, toIsoOrUndefined } from "../types/dto/iso"; import type { CheckNicknameDto, UserProfileDto } from "../types/dto/userDto"; /** @@ -46,7 +46,7 @@ function toUserProfile(user: User): UserProfileDto { provider: user.provider, favoriteTeamCode: user.favoriteTeamCode, knowledgeLevel: user.knowledgeLevel, - createdAt: toIso(user.createdAt), + createdAt: toIsoOrUndefined(user.createdAt), lastJudgedDate: user.lastJudgedDate, }; } diff --git a/src/types/dto/userDto.ts b/src/types/dto/userDto.ts index a2fb602..c62f3f8 100644 --- a/src/types/dto/userDto.ts +++ b/src/types/dto/userDto.ts @@ -1,7 +1,13 @@ import type { KnowledgeLevel, NotificationsMap, Provider, TeamCode } from "../panit"; import type { DateString } from "../dateString"; -/** 클라이언트에 노출되는 유저 프로필 응답. `createdAt`은 UTC ISO 8601 문자열. */ +/** + * 클라이언트에 노출되는 유저 프로필 응답. `createdAt`은 UTC ISO 8601 문자열. + * + * `createdAt`은 optional 이다 — serverTimestamp 가 아직 해석되지 않은 문서나 + * 필드가 없는 레거시 문서를 읽었을 때 500 을 내는 대신 키를 생략한다 + * (스프레드로 조립하던 기존 동작과 동일). + */ export interface UserProfileDto { displayName: string; email: string; @@ -9,7 +15,7 @@ export interface UserProfileDto { provider: Provider; favoriteTeamCode?: TeamCode; knowledgeLevel: KnowledgeLevel; - createdAt: string; + createdAt?: string; lastJudgedDate?: DateString; }