feat : 백엔드 core 서버 기본 세팅#8
Conversation
현재 필요한 의존성 추가 validation, security, amqp, flyway, openapi, s3, jwt, archunit, testcontainer 추가
yml 설정값 common/properties로 관리
docs의 database.md를 통해 flyway V1 추가 핵심 테이블에 대해서 인덱스 반영
user token을 encryptedToken으로 변경 consentType을 enum으로 정렬 시간 필드 Instant로 변경
status enum으로 변경 시간 Instant로 변경
status enum 변경 AnalyzedDocument source 부분 제거 후 FK관계로 정리
status 를 enum으로 변경 및 시간 Instant로 변경
status enum으로 변경 및 제약 조건 반영
HTTP 요청에 x-trace-id 부여 MDC에 저장하는 TraceFilter 추가 응답 헤더 및 어레 응답에 traceID를 포함해 ID로 추적가능 email 등등 로그에 남지 않도록 PilMasker 추가
각 계층별 의존 방향, Entitiy 위치 등 아키텍처 규칙을 ArchUnit으로 검증
JWT access token 생성/검증 Bearer token 인증 필터 추가 API 스켈레톤으로 구성
SSE emitter, event model 등추가 core AI간 비동기 메세지 기반 생성
linve, ready, health 엔드 포인트 추가
S3 및 MinIO 의존하지 않도록 추상화 하여 추가
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
| long userId, | ||
| String githubUsername | ||
| ) { | ||
| } |
| public class AuthService { | ||
|
|
||
| private static final long SKELETON_USER_ID = 1L; | ||
| private static final String SKELETON_GITHUB_USERNAME = "stackup-user"; |
There was a problem hiding this comment.
흐름 테스트를 위해서 임시 값 작성하고 나중에 로직 구현시에 없앨 예정입니다.
|
|
||
| @Column(name = "expires_at", nullable = false) | ||
| private LocalDateTime expiresAt; | ||
| private Instant expiresAt; |
There was a problem hiding this comment.
[질문] 오 Instant는 어떤 차이가 있나요. 시간대 표현 시 저 방식이 더 효과적일까요?
There was a problem hiding this comment.
기존 LocalDatetime 자체가 상대적으로 표시가 될 수 있어서
UTC 같은 시간대를 표시한 Instant를 통해 절대적인 시간 계산이 돼서 토큰 관리가 효과적일 거 같습니다.
| private final AuthService authService; | ||
|
|
||
| public AuthController(AuthService authService) { | ||
| this.authService = authService; |
There was a problem hiding this comment.
이 부분 보다는 자동 DI 사용하는편이 좋아보입니다.
스프링이 알아서 DI 해줄거에요 저거 안써도
There was a problem hiding this comment.
오 다른 방법이 있군요 한번 찾아보겠습니다.
There was a problem hiding this comment.
찾아본결과 record클래스로 변경하는거 같아서 controller를 record로 변경했습니다.
| ACCESS_DENIED(HttpStatus.FORBIDDEN, "접근 권한이 없습니다."), | ||
|
|
||
| SYS_RATE_LIMITED(HttpStatus.TOO_MANY_REQUESTS, "요청이 너무 많습니다."), | ||
| SYS_DEPENDENCY_DOWN(HttpStatus.SERVICE_UNAVAILABLE, "필수 외부 의존성이 응답하지 않습니다."), |
| @RestControllerAdvice | ||
| public class GlobalExceptionHandler { | ||
|
|
||
| @ExceptionHandler(DomainException.class) |
There was a problem hiding this comment.
DomainException이 하위 예외들의 부모라면 여기서 함께 잡히지 않을까 싶네요
GlobalExceptionHandler 에서는 하위 예외들도 모두 정의하는걸까요?
There was a problem hiding this comment.
각 하위 예외들이 GlobalExceptionHanlder에 잡혀서 도메인에 대한 예외를 처리해 구조를 단순화를 하려고 했고 각 상황에 맞는 ApiErrorCode (enum)으로 응답 형식을 통일하려고 했습니다.
| @@ -0,0 +1,105 @@ | |||
| package com.stackup.stackup.common.log; | |||
There was a problem hiding this comment.
log 하위에 있는 이유는 로깅 시 사용자 개인정보를 제거하기 위해서일까요?
There was a problem hiding this comment.
맞습니다 로그에 남길시 개인정보를 남기지 않기 위한 마스킹 유틸이고 log과 연관이 깊다고 생각해서 log 하위애 두었습니다.
| public class RabbitMessagePublisher { | ||
|
|
||
| private static final String VERSION = "v1"; | ||
| private static final String PUBLISHER = "core-server"; |
There was a problem hiding this comment.
이부분은 아예 yml 이나 다른 쪽으로 빼는것도 좋아보입니다.
There was a problem hiding this comment.
해당 변수 yml로 빼도록 하겠습니다.
There was a problem hiding this comment.
해당 변수 뿐만 아니라 RabbitMQ관련 하드코딩된 변수들 전부 applicaion.yml로 옮겨서 properties에 주입해 사용하도록 변경했습니다.
|
|
||
| public class StorageException extends RuntimeException { | ||
|
|
||
| public StorageException(String message) { |
There was a problem hiding this comment.
StorageExcpetion은 저장소 관련 오류를 모두 정의하는 듯 하네요.
DomainException과는 어떻게 연관되는지 궁금합니다.
그리고 StorageException 전용 Type도 만들어두면 좋을듯합니다.
There was a problem hiding this comment.
StorageExcpetion의 경우 저장소 관련 인프라 예외기 때문에DomainException과는 연결이 되어있지 않습니다. 지금 구조에는 Exception.class로 핸들러가 처리하기 때문에 전용 Type 만들도록 하겠습니다.
There was a problem hiding this comment.
Storage전용 Type 만들고 GlobalHandler가 StorageExcpetion 잡도록 만들었습니다.
| @Table( | ||
| name = "analyzed_documents", | ||
| indexes = { | ||
| @Index(name = "idx_analyzed_docs_source", columnList = "source_type, source_id") |
application: rabbit MQ message관련 정의 apllicaion-local: Rabbit MQ 접속을 위한 값
변경 사항
@ConfigurationProperties기반 타입 안전 설정 관리AnalyzedDocument의 sourceType/sourceId 구조 정리ObjectStorageClient포트S3ObjectStorageClient어댑터StoredObject,StorageException/api/system/live/api/system/ready/api/system/health검증