SnapFeast / core /config.py
Testys's picture
Making migrations to code after removing huggingface secrets
2333542
raw
history blame
1.61 kB
import os
from pathlib import Path
from dotenv import load_dotenv
from urllib.parse import quote_plus
from pydantic_settings import BaseSettings
load_dotenv()
class Settings(BaseSettings):
# Database settings
DATABASE_USER: str = os.getenv("PG_USER", "snapfeast_db_owner")
DATABASE_PASSWORD: str = os.getenv("PG_PASSWORD", "4fLiupkCsN5E")
DATABASE_HOST: str = os.getenv("PG_HOST", "ep-fancy-glade-a57hqsn3-pooler.us-east-2.aws.neon.tech")
DATABASE_PORT: int = os.getenv("PG_PORT", 5432)
DATABASE_NAME: str = os.getenv("PG_DATABASE", "snapdb")
JWT_SECRET_KEY: str = os.getenv("JWT_SECRET", "EjQFIgOWHqrzjZc23CfcY6RWi2F2yUMr67DRJlpkjSU")
# JWT settings
JWT_ALGORITHM: str = "HS256"
ACCESS_TOKEN_EXPIRE_MINUTES: int = int(os.getenv("ACCESS_TOKEN_EXPIRE_MINUTES", "30"))
REFRESH_TOKEN_EXPIRE_DAYS: int = int(os.getenv("REFRESH_TOKEN_EXPIRE_DAYS", "7"))
# Application settings
DEBUG: bool = os.getenv("DEBUG", "False").lower() == "true"
ALLOWED_HOSTS: list = os.getenv("ALLOWED_HOSTS", "*").split(",")
# Face recognition settings
FACE_RECOGNITION_THRESHOLD: float = float(os.getenv("FACE_RECOGNITION_THRESHOLD", "0.6"))
@property
def DATABASE_URL(self) -> str:
user = quote_plus(self.DATABASE_USER)
password = quote_plus(self.DATABASE_PASSWORD)
return f"postgresql://{user}:{password}@{self.DATABASE_HOST}:{self.DATABASE_PORT}/{self.DATABASE_NAME}?sslmode=require"
class Config:
env_file = ".env"
def get_settings() -> Settings:
return Settings()
# Usage example
settings = get_settings()