Skip to content

chore: develop → main 릴리즈 (FE 온보딩 인프라: 시드 + Dev 토큰)#88

Merged
chanwoo7 merged 5 commits intomainfrom
develop
May 5, 2026
Merged

chore: develop → main 릴리즈 (FE 온보딩 인프라: 시드 + Dev 토큰)#88
chanwoo7 merged 5 commits intomainfrom
develop

Conversation

@chanwoo7
Copy link
Copy Markdown
Member

@chanwoo7 chanwoo7 commented May 5, 2026

Summary

마이페이지 FE 온보딩 작업 플랜의 백엔드 산출물 2건을 main에 반영한다.
가이드 문서(노션) 갱신은 코드 PR 외 별도로 이미 적용 완료.

포함된 PR

# 항목 PR
1 마이페이지 검증용 시드 데이터 인프라 (yarn prisma:seed) + MySQL 인증 plugin 호환 fix #86
2 Dev 전용 access token 발급 endpoint (POST /auth/dev/issue-token) #87

주요 변경

시드 인프라 (#86)

  • prisma/seed.ts + 9개 도메인 시드 모듈 (users / stores / orders / reviews / wishlist / recent-views / notifications / custom-drafts / search-history)
  • idempotent 정리 헬퍼 (seed-user-* / [SEED] * prefix 영역만 정리)
  • 마이페이지 API 거의 모든 분기를 한 번에 검증 가능한 시나리오 (유저 2 / 매장 2 / 상품 5 / 주문 6 / 리뷰 1 / 찜 3 / 최근본 4 / 알림 3 / 커스텀 드래프트 2 / 검색 3)
  • production 환경에서 명시적 차단

Dev 토큰 헬퍼 (#87)

  • POST /auth/dev/issue-token: NODE_ENV=production 차단 + body 검증 + signAccessToken 재사용
  • AuthService.issueDevAccessToken(accountId) + findAccountForJwt 활성 USER 검증

부수 변경 (#86)

  • docker-compose.yml: --default-authentication-plugin=mysql_native_password 옵션
  • docker/mysql/init/01-grant-shadow-db.sql: ALTER USER 한 줄 (이중 안전망)
    • prisma client 6.x가 일부 환경에서 caching_sha2_password를 sha256_password로 잘못 인식하는 호환 이슈 회피

정량 결과

  • 868 → 875 tests (+7, Dev 토큰 헬퍼 회귀)
  • branches 86.5%대 유지 (임계값 86 통과)
  • 시드는 src/ 영향 없음, 신규 endpoint는 production에서 자동 차단

Breaking 여부

  • ❌ 운영 영향 없음
  • /auth/dev/issue-token: production에서 자동 차단
  • 시드: production에서 자동 차단
  • MySQL 인증 plugin 변경: 새 셋업 시 자동 적용 (기존 컨테이너 영향 없음)
  • 마이그레이션: 없음

Test plan

  • 두 feature PR 모두 develop CI 통과 후 머지
  • 로컬 yarn test:cov 통과 (875 tests)
  • yarn prisma:seed 첫/두 번째/세 번째 실행 모두 성공 (idempotent)
  • NODE_ENV=production 시 시드 + dev 토큰 모두 차단 확인
  • main 머지 시 CI check / coverage / pr-title / CodeQL 모두 통과

Summary by CodeRabbit

릴리스 노트

  • 새 기능

    • 개발 전용 토큰 발급 엔드포인트 추가
    • 자동화된 시드 데이터 생성 시스템 구현
    • GraphQL 코드 생성 및 문서화 도구 통합
  • 기타

    • 데이터베이스 인증 방식 및 문자 인코딩 설정 최적화
    • 개발 및 테스트 환경 인프라 개선

chanwoo7 added 5 commits May 6, 2026 04:22
FE 개발자가 로컬에서 마이페이지 API 전반을 시각적으로 검증할 수 있도록
prisma db seed 명령으로 한 번에 채울 수 있는 테스트 데이터 인프라를 도입한다.

## 구현

- package.json
  - scripts.prisma:seed
  - prisma.seed: ts-node + tsconfig-paths 기반 entry
- prisma/seed.ts: entry point (production 가드 포함)
- prisma/seed/idempotent.ts: 시드 영역(seed-user-* / [SEED] *) 정리 헬퍼
- prisma/seed/{users,stores,orders,reviews,wishlist,recent-views,
  notifications,custom-drafts,search-history}.ts

## 시드 시나리오

마이페이지 API 거의 모든 분기를 한 번에 검증할 수 있도록 구성:
- 유저 2명 (온보딩 완료 / 미완료)
- 매장 2개 + 상품 5개 (sale_price 있음/없음, 비활성 1)
- 주문 6건 (각 status + PICKED_UP에 리뷰 작성/미작성 둘 다)
  - o2에 selectedOptions/customTexts/customFreeEdits 포함
- 리뷰 1건 (IMAGE+VIDEO 미디어 포함)
- 찜 3건 (visible 2 + invisible 1로 visibleWishlistWhere 검증)
- 최근 본 상품 4건
- 알림 3건 (unread 2 / read 1)
- 커스텀 드래프트 2건 (IN_PROGRESS / READY_FOR_ORDER)
- 검색 히스토리 3건

## 부수 변경

docker-compose.yml과 docker/mysql/init/01-grant-shadow-db.sql:
- prisma client 6.x가 일부 환경에서 caching_sha2_password를
  sha256_password로 잘못 인식하는 호환 이슈 회피.
- mysql_native_password로 통일 (default-authentication-plugin
  옵션 + ALTER USER 이중 안전망).

README.md: 테스트 데이터 시드 사용법 섹션 추가.

## 검증

- 첫 실행 / 두 번째 실행 모두 성공 (idempotent)
- NODE_ENV=production 차단 동작 확인
- npx tsc --noEmit 통과
feat: 마이페이지 검증용 시드 데이터 인프라 추가
FE 개발자가 시드(yarn prisma:seed) accountId로 OIDC 흐름을 거치지 않고
GraphQL Playground에서 곧장 마이페이지 API를 시험할 수 있도록 dev 전용 헬퍼 추가.

## 변경 사항

- AuthService.issueDevAccessToken(accountId)
  - findAccountForJwt로 활성 USER 검증 (NotFound / Forbidden 분기)
  - 기존 signAccessToken을 재사용하여 access token 생성
- AuthController.devIssueToken (POST /auth/dev/issue-token)
  - NODE_ENV=production이면 ForbiddenException으로 즉시 차단
  - body.accountId 누락/형식 오류 시 BadRequestException
  - 응답: { accessToken, tokenType: 'Bearer', expiresInSeconds }

## 회귀 테스트

- auth.service.spec.ts: 정상 발급 / NotFound / Forbidden 3건
- auth.controller.spec.ts: production 차단 / 누락 / 형식오류 / 정상 4건

전체 875 tests 통과 (+7).
feat(auth): dev 전용 access token 발급 endpoint 추가
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 5, 2026

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 012f1eb9-edfb-415c-ab44-7097da5d5e91

📥 Commits

Reviewing files that changed from the base of the PR and between 81fd6c9 and 12239a9.

📒 Files selected for processing (18)
  • docker-compose.yml
  • docker/mysql/init/01-grant-shadow-db.sql
  • package.json
  • prisma/seed.ts
  • prisma/seed/custom-drafts.ts
  • prisma/seed/idempotent.ts
  • prisma/seed/notifications.ts
  • prisma/seed/orders.ts
  • prisma/seed/recent-views.ts
  • prisma/seed/reviews.ts
  • prisma/seed/search-history.ts
  • prisma/seed/stores.ts
  • prisma/seed/users.ts
  • prisma/seed/wishlist.ts
  • src/features/auth/auth.service.spec.ts
  • src/features/auth/auth.service.ts
  • src/features/auth/controllers/auth.controller.spec.ts
  • src/features/auth/controllers/auth.controller.ts

📝 Walkthrough

Walkthrough

이 PR은 개발 환경을 위한 데이터베이스 시딩 인프라와 관리용 JWT 토큰 발급 기능을 추가합니다. MySQL 인증 플러그인 설정, Prisma 시드 스크립트(사용자, 스토어, 주문, 리뷰 등), 그리고 인증 서비스에 개발용 토큰 발급 엔드포인트를 도입합니다.

Changes

데이터베이스 및 시딩 인프라

레이어 / 파일(s) 요약
MySQL 구성
docker-compose.yml, docker/mysql/init/01-grant-shadow-db.sql
MySQL 네이티브 암호 인증 플러그인과 UTF-8mb4 문자 인코딩 설정 추가; 기존 caquick 사용자의 인증 방식 변경
패키지 설정 및 시드 스크립트
package.json
prisma:seed, graphql:codegen, graphql:docs, prepare 스크립트와 Prisma 시드 설정 추가
시드 데이터 타입 및 헬퍼
prisma/seed/idempotent.ts, prisma/seed/users.ts, prisma/seed/stores.ts
시드 데이터 식별자 상수, 사용자/프로필 생성, 스토어/상품/옵션 그룹 생성을 위한 기초 인터페이스 및 함수 정의
주문 및 관련 데이터 시딩
prisma/seed/orders.ts, prisma/seed/reviews.ts
다양한 주문 상태와 항목, 옵션, 첨부파일, 리뷰 및 미디어 생성
사용자 활동 시딩
prisma/seed/recent-views.ts, prisma/seed/wishlist.ts, prisma/seed/notifications.ts, prisma/seed/search-history.ts, prisma/seed/custom-drafts.ts
최근 조회 기록, 위시리스트, 알림, 검색 이력, 커스텀 드래프트 데이터 생성
시드 오케스트레이션
prisma/seed.ts
모든 시드 모듈을 순차적으로 실행하며 프로덕션 실행 차단, 정리 작업 관리, 생성된 테스트 계정 출력
시드 정리 유틸리티
prisma/seed/idempotent.ts (정리 로직)
시드 데이터 식별 및 깊이 우선 삭제를 통한 완전한 정리(사용자/스토어/판매자 계정 관련 모든 데이터 포함)

개발용 인증 토큰 발급 기능

레이어 / 파일(s) 요약
인증 서비스 기능
src/features/auth/auth.service.ts
계정 검증 및 JWT 서명을 통한 issueDevAccessToken(accountId) 메서드 추가
컨트롤러 엔드포인트
src/features/auth/controllers/auth.controller.ts
프로덕션 환경 차단 로직과 함께 POST /auth/dev/issue-token 엔드포인트 및 입력 검증 헬퍼 함수 추가
테스트
src/features/auth/auth.service.spec.ts, src/features/auth/controllers/auth.controller.spec.ts
정상 발급, 미존재 계정, 비활성 계정, 프로덕션 차단 시나리오에 대한 테스트 추가

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~60분

Possibly related PRs

  • CaQuick/caquick-be#15: 동일한 AuthService 구현 파일 수정 — 본 PR의 issueDevAccessToken 추가와 검색된 PR의 sellerLogin 변경이 같은 클래스 내에서 이루어짐
  • CaQuick/caquick-be#32: 동일한 AuthService 클래스 수정 — 검색된 PR에서 ClockService 주입 및 Date 사용 변경, 본 PR에서 issueDevAccessToken 메서드와 컨트롤러 변경이 같은 파일에서 발생
  • CaQuick/caquick-be#26: 본 PR의 Prisma 시드 모듈(사용자, 스토어, 주문, 리뷰, 최근 조회 등) 및 MySQL 인증/설정 변경이 검색된 PR의 스키마 및 기능 작업(ReviewMedia, RecentProductView, S3/스토리지 + 리뷰/최근 조회 서비스)과 직접 상호 보완적 관계
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch develop

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 Trivy (0.69.3)

Failed to read Trivy output file: ENOENT: no such file or directory, open '/inmem/1278/nsjail-bbd846d9-59b3-4f98-ab22-8db1c509a99f/merged/.trivy-output.json'


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@chanwoo7 chanwoo7 enabled auto-merge May 5, 2026 23:04
@github-actions
Copy link
Copy Markdown

github-actions Bot commented May 5, 2026

Coverage report

St.
Category Percentage Covered / Total
🟢 Statements 96.71% 2912/3011
🟢 Branches 86.52% 1656/1914
🟢 Functions 93.35% 618/662
🟢 Lines 97.04% 2656/2737

Test suite run success

875 tests passing in 77 suites.

Report generated by 🧪jest coverage report action from 12239a9

@codecov
Copy link
Copy Markdown

codecov Bot commented May 5, 2026

Codecov Report

❌ Patch coverage is 94.73684% with 1 line in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
src/features/auth/controllers/auth.controller.ts 91.66% 0 Missing and 1 partial ⚠️

📢 Thoughts on this report? Let us know!

@chanwoo7 chanwoo7 merged commit e27fdfb into main May 5, 2026
12 of 13 checks passed
@chanwoo7 chanwoo7 deleted the develop branch May 5, 2026 23:05
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 12239a91cc

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread prisma/seed/idempotent.ts
where: { product_id: { in: productIds } },
});

await prisma.product.deleteMany({ where: { id: { in: productIds } } });
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Delete all FK dependents before removing seeded products

resetSeedScope removes cart/wishlist/recent-view references for seeded products but does not clear other required dependents (for example OrderItem and Review rows from non-seed accounts that referenced those products/stores). In any shared dev DB where someone orders or reviews a [SEED] product, this product.deleteMany call will fail on FK constraints and the script stops being idempotent after one run.

Useful? React with 👍 / 👎.

@Body() body: DevIssueTokenBody,
@Res() res: Response,
): Promise<void> {
if (process.env.NODE_ENV === 'production') {
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Block dev token issuance outside explicit local/dev envs

This endpoint is unauthenticated and currently disabled only when NODE_ENV is exactly 'production', so it remains enabled in other deployed modes (e.g., staging, qa, or unset). In those environments, anyone who can reach the API can mint access tokens for arbitrary account IDs and impersonate users; a dev helper like this should be gated by an explicit allowlist/feature flag, not just a production inequality check.

Useful? React with 👍 / 👎.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant