40 lines
1.2 KiB
Python
40 lines
1.2 KiB
Python
import os
|
|
import secrets
|
|
from typing import List, Union
|
|
|
|
from pydantic import AnyHttpUrl, field_validator
|
|
from pydantic_settings import BaseSettings
|
|
|
|
|
|
class Settings(BaseSettings):
|
|
API_V1_STR: str = "/api/v1"
|
|
SECRET_KEY: str = os.environ.get("SECRET_KEY", secrets.token_urlsafe(32))
|
|
# 60 minutes * 24 hours * 8 days = 8 days
|
|
ACCESS_TOKEN_EXPIRE_MINUTES: int = 60 * 24 * 8
|
|
|
|
# CORS configuration
|
|
BACKEND_CORS_ORIGINS: List[AnyHttpUrl] = []
|
|
|
|
@field_validator("BACKEND_CORS_ORIGINS", mode="before")
|
|
def assemble_cors_origins(cls, v: Union[str, List[str]]) -> Union[List[str], str]:
|
|
if isinstance(v, str) and not v.startswith("["):
|
|
return [i.strip() for i in v.split(",")]
|
|
elif isinstance(v, (list, str)):
|
|
return v
|
|
raise ValueError(v)
|
|
|
|
PROJECT_NAME: str = "Role-Based School Management System"
|
|
|
|
# Environment
|
|
ENVIRONMENT: str = os.environ.get("ENVIRONMENT", "development")
|
|
|
|
# Database configuration
|
|
SQLALCHEMY_DATABASE_URL: str = os.environ.get(
|
|
"DATABASE_URL", "sqlite:////app/storage/db/db.sqlite"
|
|
)
|
|
|
|
# JWT token configuration
|
|
JWT_SECRET_KEY: str = os.environ.get("JWT_SECRET_KEY", SECRET_KEY)
|
|
JWT_ALGORITHM: str = "HS256"
|
|
|
|
settings = Settings() |