- Integrated image-service from site00 as second microservice - Maintained proxy and caching functionality - Added Images service to docker-compose - Configured Console API Gateway routing to Images - Updated environment variables in .env - Successfully tested image proxy endpoints Services now running: - Console (API Gateway) - Users Service - Images Service (proxy & cache) - MongoDB & Redis Next: Kafka event system implementation 🤖 Generated with Claude Code Co-Authored-By: Claude <noreply@anthropic.com>
65 lines
1.5 KiB
Python
65 lines
1.5 KiB
Python
from fastapi import FastAPI
|
|
from fastapi.middleware.cors import CORSMiddleware
|
|
from contextlib import asynccontextmanager
|
|
import uvicorn
|
|
from datetime import datetime
|
|
|
|
from app.api.endpoints import router
|
|
from app.core.config import settings
|
|
|
|
@asynccontextmanager
|
|
async def lifespan(app: FastAPI):
|
|
# 시작 시
|
|
print("Images service starting...")
|
|
yield
|
|
# 종료 시
|
|
print("Images service stopping...")
|
|
|
|
app = FastAPI(
|
|
title="Images Service",
|
|
description="이미지 업로드, 프록시 및 캐싱 서비스",
|
|
version="2.0.0",
|
|
lifespan=lifespan
|
|
)
|
|
|
|
# CORS 설정
|
|
app.add_middleware(
|
|
CORSMiddleware,
|
|
allow_origins=["*"],
|
|
allow_credentials=True,
|
|
allow_methods=["*"],
|
|
allow_headers=["*"],
|
|
)
|
|
|
|
# 라우터 등록
|
|
app.include_router(router, prefix="/api/v1")
|
|
|
|
@app.get("/")
|
|
async def root():
|
|
return {
|
|
"service": "Images Service",
|
|
"version": "2.0.0",
|
|
"timestamp": datetime.now().isoformat(),
|
|
"endpoints": {
|
|
"proxy": "/api/v1/image?url=<image_url>&size=<optional_size>",
|
|
"upload": "/api/v1/upload",
|
|
"stats": "/api/v1/stats",
|
|
"cleanup": "/api/v1/cleanup"
|
|
}
|
|
}
|
|
|
|
@app.get("/health")
|
|
async def health_check():
|
|
return {
|
|
"status": "healthy",
|
|
"service": "images",
|
|
"timestamp": datetime.now().isoformat()
|
|
}
|
|
|
|
if __name__ == "__main__":
|
|
uvicorn.run(
|
|
"main:app",
|
|
host="0.0.0.0",
|
|
port=8000,
|
|
reload=True
|
|
) |