35 lines
801 B
Python
35 lines
801 B
Python
import os
|
|
from pathlib import Path
|
|
from typing import ClassVar
|
|
|
|
from pydantic import BaseModel, Field
|
|
|
|
|
|
class Settings(BaseModel):
|
|
PROJECT_NAME: str = "Notes API"
|
|
API_V1_STR: str = "/api/v1"
|
|
|
|
# Security
|
|
SECRET_KEY: str = os.getenv("SECRET_KEY", "please_change_this_to_a_random_secret_key")
|
|
ACCESS_TOKEN_EXPIRE_MINUTES: int = 60 * 24 * 7 # 7 days
|
|
|
|
# Database
|
|
DB_DIR: ClassVar[Path] = Path("/app/storage/db")
|
|
SQLALCHEMY_DATABASE_URL: str = Field(
|
|
default_factory=lambda: f"sqlite:///{Settings.DB_DIR}/db.sqlite"
|
|
)
|
|
|
|
# CORS
|
|
CORS_ORIGINS: list[str] = ["*"]
|
|
|
|
model_config = {
|
|
"env_file": ".env",
|
|
"case_sensitive": True,
|
|
}
|
|
|
|
|
|
# Create the database directory
|
|
Settings.DB_DIR.mkdir(parents=True, exist_ok=True)
|
|
|
|
settings = Settings()
|