66 lines
1.8 KiB
Python
66 lines
1.8 KiB
Python
"""
|
|
Application configuration
|
|
"""
|
|
from pydantic_settings import BaseSettings
|
|
from pydantic import Field
|
|
|
|
|
|
class Settings(BaseSettings):
|
|
"""Application settings"""
|
|
|
|
# Application
|
|
app_name: str = "Cosmo - Deep Space Explorer"
|
|
api_prefix: str = "/api"
|
|
|
|
# CORS settings - allow all origins for development (IP access support)
|
|
cors_origins: list[str] = ["*"]
|
|
|
|
# Cache settings
|
|
cache_ttl_days: int = 3
|
|
|
|
# JWT settings
|
|
jwt_secret_key: str = "your-secret-key-change-this-in-production"
|
|
jwt_algorithm: str = "HS256"
|
|
jwt_access_token_expire_minutes: int = 60 * 24 # 24 hours
|
|
|
|
# Database settings (PostgreSQL)
|
|
database_host: str = "localhost"
|
|
database_port: int = 5432
|
|
database_name: str = "cosmo_db"
|
|
database_user: str = "postgres"
|
|
database_password: str = "postgres"
|
|
database_pool_size: int = 20
|
|
database_max_overflow: int = 10
|
|
|
|
# Redis settings
|
|
redis_host: str = "localhost"
|
|
redis_port: int = 6379
|
|
redis_db: int = 0
|
|
redis_password: str = ""
|
|
redis_max_connections: int = 50
|
|
|
|
# File upload settings
|
|
upload_dir: str = "upload"
|
|
max_upload_size: int = 10485760 # 10MB
|
|
|
|
@property
|
|
def database_url(self) -> str:
|
|
"""Construct database URL for SQLAlchemy"""
|
|
return (
|
|
f"postgresql+asyncpg://{self.database_user}:{self.database_password}"
|
|
f"@{self.database_host}:{self.database_port}/{self.database_name}"
|
|
)
|
|
|
|
@property
|
|
def redis_url(self) -> str:
|
|
"""Construct Redis URL"""
|
|
if self.redis_password:
|
|
return f"redis://:{self.redis_password}@{self.redis_host}:{self.redis_port}/{self.redis_db}"
|
|
return f"redis://{self.redis_host}:{self.redis_port}/{self.redis_db}"
|
|
|
|
class Config:
|
|
env_file = ".env"
|
|
|
|
|
|
settings = Settings()
|