Repository navigation
refactor(web): src와 server의 책임 경계 정리 - #173
Merged
Merged
Conversation
src/의 모호한 공용 폴더에 있던 서버 전용 파일 두 개를 실제 소비 계층으로 옮긴다. 둘 다 HTTP 계약과 무관하며 소비자가 서버 한 곳뿐이다. - src/lib/Holder.ts -> server/infra/database/connection-holder.ts 유일한 소비자는 datasource.ts이고, 실제 역할은 첫 database connection이 준비될 때까지 service proxy를 대기시키는 것이다. 범용 서버 도구가 아니라 database 초기화 장치이므로 이름과 위치를 그에 맞춘다. - src/common/utils/formatYearMonth.ts -> server/domain/club/recruitment-year-month.ts 문자열 포맷 도구가 아니라 모집공고 yearMonth 값의 생성 규칙이다. club-recruitment.service.ts와 club-recruitment.entity.ts가 같은 규칙을 적용하므로 모집공고 domain에 둔다. 동작은 그대로 둔다. Holder의 Promise 동작과 formatYearMonth의 로컬 시간 계산은 손대지 않았고, 이름 정리나 시간대 정책 변경은 별도 작업이다. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
src/lib/app-links.test.ts -> tests/deployment/app-links.test.ts 이 테스트가 node:fs와 createRequire를 쓴다는 사실은 서버 domain에 속한다는 증거가 아니다. 실패하는 사건을 보면 위치가 드러난다. AASA 파일에서 경로가 빠질 때, iOS entitlement에서 associated domain이 사라질 때, Android manifest와 인증서 등록이 어긋날 때, Next.js가 association 파일의 JSON header를 잃을 때 실패한다. 하나의 서버 모듈이 아니라 배포되는 여러 플랫폼 사이의 약속을 검사하므로 tests/deployment가 그 실패 이유를 이름으로 드러낸다. 경로 가정은 그대로 유지된다. process.cwd() 기준 웹·모바일·workflow 파일 읽기는 영향이 없고, 새 위치도 기존과 같은 두 단계 깊이라 next.config.js의 상대 경로 ../../ 가 그대로 성립한다. App Links 설정을 바꾸는 PR이 이 이동만 독립적으로 되돌리거나 수정할 수 있도록 별도 커밋으로 둔다. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
앞선 세 커밋이 서버의 타입, 상수, HTTP 계약을 server로 되돌렸지만 합의만으로는 되돌아가는 길이 열려 있다. 서버 정책이 다시 src/common에 추가되어도 지금은 아무 검사도 막지 못한다. noRestrictedImports로 두 방향을 차단한다. server/** ─X→ src/** src/** ─X→ server/service, server/provider, server/infra bare specifier와 상대 경로를 모두 막도록 각 group에 `**/` 접두 패턴을 함께 둔다. pages/api와 middleware는 서버 진입점이므로 대상이 아니다. src가 server/domain과 server/http/schemas를 참조하는 것은 허용한다. 현재 규칙은 type-only 여부를 표현하지 못하므로, 이 두 경로에서 값을 import할 때 브라우저 bundle에 서버 의존이 섞이지 않는지는 코드 리뷰가 계속 판단한다. 자동 검사는 위험한 실행 계층만 책임진다. biome check, typecheck, 전체 테스트와 프로덕션 빌드를 통과한다. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
9 of 15 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
작업 내용
apps/web에서 서버가 소유해야 하는 코드와 프론트엔드 중심 코드가src에 섞여 있던 구조를 정리했다.server/domain/model을 공식 기준으로 통합server/domain/constants로 이동src/lib에서server/http로 이동yearMonth계산 규칙을 각각server/infra/database,server/domain/club으로 이동tests/deployment로 이동변경 이유
기존에는
src가 주로 웹 프론트엔드 코드 영역임에도, 서버의 도메인 타입·업무 규칙·HTTP API 계약·DB 초기화 보조 코드가 함께 위치해 있었다. 이 구조에서는 처음 코드를 읽을 때 각 파일의 책임을 파악하기 어렵고, 같은 개념을 여러 위치에서 관리하거나 서버 코드가 다시 프론트 코드에 의존하게 될 위험이 있었다.이번 정리를 통해 코드의 위치가 실제 책임을 드러내도록 개선했다.
체크