1.9 KiB
1.9 KiB
main.py 엔드포인트 라우터 이동
날짜: 2025-12-23
작성자: happybell80
관련 파일: main.py, app/router/*_endpoint.py
문제 상황
- main.py에
@app.post(),@app.get()데코레이터로 직접 정의된 엔드포인트 16개 존재 - 계층 분리 원칙 위반:
main.py는 "앱 실행, 라우터 등록만" 담당해야 함 (311_FastAPI_구조_원칙.md)
해결 방안
feedback_endpoint.py생성:main.py:89-110→app/router/feedback_endpoint.pyllm_endpoint.py확장:main.py:473-568→app/router/llm_endpoint.py:129-217(/api/llm/extract추가)llm_complete_endpoint.py생성:main.py:113-148→app/router/llm_complete_endpoint.py(/complete별도 파일)slack_endpoint.py확장:main.py:241-245→app/router/slack_endpoint.py:117-121(/interactive추가)system_endpoint.py생성:main.py:287-317,324-361,438-444→app/router/system_endpoint.pyschedule_endpoint.py생성:main.py:259-295→app/router/schedule_endpoint.pydm_endpoint.py확장:main.py:364-435→app/router/dm_endpoint.py(/send-email-summary추가, JWT 인증 추가)history_endpoint.py생성:main.py:447-522→app/router/history_endpoint.py- 의존성 주입:
system_endpoint.py:18-21(set_router_instance),schedule_endpoint.py:18-21(set_scheduler) - TDD 진행: 각 엔드포인트별 테스트 파일 작성 후 구현
구현 완료
- 모든 엔드포인트 router로 이동 완료
- main.py에 남은
@app.데코레이터는@app.on_event()만 남음 (이벤트 핸들러) - e2e 테스트 통과 확인
교훈
- 원칙 준수: main.py는 라우터 등록만 담당하도록 엄격히 분리
- 의존성 주입: router, scheduler 등 인스턴스는 함수로 주입하는 패턴 사용
- TDD: 테스트 먼저 작성 후 구현하여 안정성 확보