-
Notifications
You must be signed in to change notification settings - Fork 0
Description
📄 작업 내용 or 논의 내용
- 서버 라우트에서 사용할 공통 유틸 함수를 작성합니다.
src/utils/sever/하위에 작성합니다.
요청/응답 관련
safeFetch.ts- fetch 요청을 안전하게 수행
- 요청 실패 시, 서버/클라이언트 에러 메세지 구분
parseBody.ts- request.json() 호출 + 유효성 체크 + 에러 처리
parseQuery.tsURLSearchParams에서 query 파라미터를 안전하게 추출
jsonResponse.ts- `NextResponse.json() 호출 시 status, 헤더 등의 일관성 유지
에러 처리
handlerServerError.ts- 서버 에러 처리 후 로깅, 메세지 형식 통일
handlerClientError.ts- 클라이언트 요청 오류 처리 (400, 404 등)
validateRequest.ts- body/query 필드 검증 실패 시 에러 반환
인증/권한
getUser.ts- 서버 라우트에서 유저 인증 정보 추출
requireAuth.ts- 인증 필요 라우트에 적용 (인증 실패 시 401 반환)
🙋🏻 참고 자료
No response
Reactions are currently unavailable
Sub-issues
Metadata
Metadata
Assignees
Labels
No labels