diff --git a/.env.development.template b/.env.development.template new file mode 100644 index 0000000..d76faef --- /dev/null +++ b/.env.development.template @@ -0,0 +1,55 @@ +# Development Environment Configuration +# Copy this file to .env for development setup + +# Application Configuration +HOST=localhost +PORT=8000 +RELOAD=true + +# Development URLs (for local development) +FRONTEND_URL=http://localhost:8001 +BACKEND_URL=http://localhost:8000 +CORS_ORIGINS=["http://localhost:8001"] + +# Database Configuration +DATABASE_URL=sqlite+aiosqlite:///data/soundboard.db +DATABASE_ECHO=false + +# Logging Configuration +LOG_LEVEL=debug +LOG_FILE=logs/app.log +LOG_MAX_SIZE=10485760 +LOG_BACKUP_COUNT=5 + +# JWT Configuration (Use a secure key even in development) +JWT_SECRET_KEY=development-secret-key-change-for-production +JWT_ACCESS_TOKEN_EXPIRE_MINUTES=15 +JWT_REFRESH_TOKEN_EXPIRE_DAYS=7 + +# Cookie Configuration (Development settings) +COOKIE_SECURE=false +COOKIE_SAMESITE=lax +COOKIE_DOMAIN=localhost + +# OAuth2 Configuration (Get these from OAuth providers) +# Google: https://console.developers.google.com/ +# Redirect URI: http://localhost:8000/api/v1/auth/google/callback +GOOGLE_CLIENT_ID=your-google-client-id +GOOGLE_CLIENT_SECRET=your-google-client-secret + +# GitHub: https://github.com/settings/developers +# Redirect URI: http://localhost:8000/api/v1/auth/github/callback +GITHUB_CLIENT_ID=your-github-client-id +GITHUB_CLIENT_SECRET=your-github-client-secret + +# Audio Normalization Configuration +NORMALIZED_AUDIO_FORMAT=mp3 +NORMALIZED_AUDIO_BITRATE=256k +NORMALIZED_AUDIO_PASSES=2 + +# Audio Extraction Configuration +EXTRACTION_AUDIO_FORMAT=mp3 +EXTRACTION_AUDIO_BITRATE=256k +EXTRACTION_TEMP_DIR=sounds/temp +EXTRACTION_THUMBNAILS_DIR=sounds/originals/extracted/thumbnails +EXTRACTION_MAX_CONCURRENT=2 \ No newline at end of file diff --git a/.env.production.template b/.env.production.template new file mode 100644 index 0000000..5004cc7 --- /dev/null +++ b/.env.production.template @@ -0,0 +1,50 @@ +# Production Environment Configuration +# Copy this file to .env and configure for your production environment + +# Application Configuration +HOST=0.0.0.0 +PORT=8000 +RELOAD=false + +# Production URLs (configure for your domain) +FRONTEND_URL=https://yourdomain.com +BACKEND_URL=https://yourdomain.com +CORS_ORIGINS=["https://yourdomain.com"] + +# Database Configuration (consider using PostgreSQL in production) +DATABASE_URL=sqlite+aiosqlite:///data/soundboard.db +DATABASE_ECHO=false + +# Logging Configuration +LOG_LEVEL=info +LOG_FILE=logs/app.log +LOG_MAX_SIZE=10485760 +LOG_BACKUP_COUNT=5 + +# JWT Configuration (IMPORTANT: Generate secure keys for production) +JWT_SECRET_KEY=your-super-secure-secret-key-change-this-in-production +JWT_ACCESS_TOKEN_EXPIRE_MINUTES=15 +JWT_REFRESH_TOKEN_EXPIRE_DAYS=7 + +# Cookie Configuration (Production settings) +COOKIE_SECURE=true +COOKIE_SAMESITE=lax +COOKIE_DOMAIN= # Leave empty for same-origin cookies in production with reverse proxy + +# OAuth2 Configuration (Configure with your OAuth providers) +GOOGLE_CLIENT_ID=your-google-client-id +GOOGLE_CLIENT_SECRET=your-google-client-secret +GITHUB_CLIENT_ID=your-github-client-id +GITHUB_CLIENT_SECRET=your-github-client-secret + +# Audio Normalization Configuration +NORMALIZED_AUDIO_FORMAT=mp3 +NORMALIZED_AUDIO_BITRATE=256k +NORMALIZED_AUDIO_PASSES=2 + +# Audio Extraction Configuration +EXTRACTION_AUDIO_FORMAT=mp3 +EXTRACTION_AUDIO_BITRATE=256k +EXTRACTION_TEMP_DIR=sounds/temp +EXTRACTION_THUMBNAILS_DIR=sounds/originals/extracted/thumbnails +EXTRACTION_MAX_CONCURRENT=2 \ No newline at end of file diff --git a/app/api/v1/auth.py b/app/api/v1/auth.py index ff4a078..24d2918 100644 --- a/app/api/v1/auth.py +++ b/app/api/v1/auth.py @@ -207,14 +207,14 @@ async def logout( httponly=True, secure=settings.COOKIE_SECURE, samesite=settings.COOKIE_SAMESITE, - domain="localhost", # Match the domain used when setting cookies + domain=settings.COOKIE_DOMAIN, # Match the domain used when setting cookies ) response.delete_cookie( key="refresh_token", httponly=True, secure=settings.COOKIE_SECURE, samesite=settings.COOKIE_SAMESITE, - domain="localhost", # Match the domain used when setting cookies + domain=settings.COOKIE_DOMAIN, # Match the domain used when setting cookies ) return {"message": "Successfully logged out"} @@ -303,7 +303,7 @@ async def oauth_callback( "created_at": time.time(), } - redirect_url = f"http://localhost:8001/auth/callback?code={temp_code}" + redirect_url = f"{settings.FRONTEND_URL}/auth/callback?code={temp_code}" logger.info("Redirecting to: %s", redirect_url) return RedirectResponse( diff --git a/app/api/v1/main.py b/app/api/v1/main.py index 785bd29..fd28bd5 100644 --- a/app/api/v1/main.py +++ b/app/api/v1/main.py @@ -1,6 +1,7 @@ """Main router for v1 endpoints.""" from fastapi import APIRouter +from fastapi.responses import HTMLResponse from app.core.logging import get_logger from app.schemas.common import HealthResponse @@ -15,3 +16,69 @@ def health() -> HealthResponse: """Health check endpoint.""" logger.info("Health check endpoint accessed") return HealthResponse(status="healthy") + + +@router.get("/scalar-docs", response_class=HTMLResponse) +def scalar_docs() -> HTMLResponse: + """Serve the API documentation using Scalar.""" + return """ + + +
+