Add sub-projects
This commit is contained in:
26
packages/sshecret-backend/src/sshecret_backend/settings.py
Normal file
26
packages/sshecret-backend/src/sshecret_backend/settings.py
Normal file
@ -0,0 +1,26 @@
|
||||
"""Settings management."""
|
||||
|
||||
import os
|
||||
from pathlib import Path
|
||||
from pydantic import BaseModel
|
||||
from dotenv import load_dotenv
|
||||
|
||||
DEFAULT_DATABASE = "sshecret.db"
|
||||
|
||||
|
||||
load_dotenv()
|
||||
|
||||
|
||||
class BackendSettings(BaseModel):
|
||||
"""Backend Settings."""
|
||||
|
||||
db_file: Path
|
||||
regenerate_tokens: bool = False
|
||||
|
||||
|
||||
def get_settings() -> BackendSettings:
|
||||
"""Get settings."""
|
||||
db_filename = os.getenv("SSHECRET_DATABASE") or DEFAULT_DATABASE
|
||||
db_file = Path(db_filename).absolute()
|
||||
|
||||
return BackendSettings(db_file=db_file)
|
||||
Reference in New Issue
Block a user