prod: UI Optimisée mise en production
- Documentation archivée et réorganisée - Backend: Ajout tests, migrations, library service, rate limiting - Frontend: Suppression Flutter, focus sur interface web HTML/JS - Tailwind CSS ajouté pour le style - Améliorations UX et corrections bugs Generated with [Claude Code](https://claude.com/claude-code) via [Happy](https://happy.engineering) Co-Authored-By: Claude <noreply@anthropic.com> Co-Authored-By: Happy <yesreply@happy.engineering>
This commit is contained in:
+17
-8
@@ -1,4 +1,5 @@
|
||||
"""Main FastAPI application entry point."""
|
||||
import logging
|
||||
from contextlib import asynccontextmanager
|
||||
from pathlib import Path
|
||||
from typing import AsyncGenerator
|
||||
@@ -7,9 +8,13 @@ from fastapi import FastAPI, Request
|
||||
from fastapi.middleware.cors import CORSMiddleware
|
||||
from fastapi.responses import JSONResponse, HTMLResponse
|
||||
from fastapi.staticfiles import StaticFiles
|
||||
from slowapi.errors import RateLimitExceeded
|
||||
|
||||
from app.core.config import settings
|
||||
from app.core.database import close_db, init_db
|
||||
from app.core.rate_limiter import limiter
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
# Get the base directory
|
||||
@@ -24,22 +29,22 @@ async def lifespan(app: FastAPI) -> AsyncGenerator[None, None]:
|
||||
Handles startup and shutdown events.
|
||||
"""
|
||||
# Startup
|
||||
print("Starting up...")
|
||||
logger.info("Starting up...")
|
||||
if settings.DEBUG:
|
||||
print("Debug mode is ON")
|
||||
print(f"Database URL: {settings.DATABASE_URL}")
|
||||
print(f"Redis URL: {settings.FULL_REDIS_URL}")
|
||||
logger.debug("Debug mode is ON")
|
||||
logger.debug(f"Database URL: {settings.DATABASE_URL}")
|
||||
logger.debug(f"Redis URL: {settings.FULL_REDIS_URL}")
|
||||
|
||||
# Initialize database
|
||||
await init_db()
|
||||
print("Database initialized")
|
||||
logger.info("Database initialized")
|
||||
|
||||
yield
|
||||
|
||||
# Shutdown
|
||||
print("Shutting down...")
|
||||
logger.info("Shutting down...")
|
||||
await close_db()
|
||||
print("Database connections closed")
|
||||
logger.info("Database connections closed")
|
||||
|
||||
|
||||
# Create FastAPI application
|
||||
@@ -53,6 +58,9 @@ app = FastAPI(
|
||||
lifespan=lifespan,
|
||||
)
|
||||
|
||||
# Set up rate limiting
|
||||
app.state.limiter = limiter
|
||||
|
||||
|
||||
# Configure CORS
|
||||
app.add_middleware(
|
||||
@@ -109,11 +117,12 @@ async def global_exception_handler(request, exc) -> JSONResponse:
|
||||
|
||||
|
||||
# API routes
|
||||
from app.api.v1 import auth, music, playlists
|
||||
from app.api.v1 import auth, music, playlists, library
|
||||
|
||||
app.include_router(auth.router, prefix=settings.API_V1_PREFIX, tags=["authentication"])
|
||||
app.include_router(music.router, prefix=settings.API_V1_PREFIX, tags=["music"])
|
||||
app.include_router(playlists.router, prefix=settings.API_V1_PREFIX, tags=["playlists"])
|
||||
app.include_router(library.router, prefix=settings.API_V1_PREFIX, tags=["library"])
|
||||
|
||||
# Mount static files
|
||||
static_dir = BASE_DIR / "app" / "static"
|
||||
|
||||
Reference in New Issue
Block a user