2024-12-26 14:42:24 +02:00

35 lines
1.3 KiB
Python

from typing import Annotated
from pydantic import AnyUrl, BeforeValidator, Field, HttpUrl, RedisDsn
from service.constants import LogLevel
from service.constants.system import Environment
from service.helpers.settings import ProjectBaseSettings, parse_cors
class ProjectSettings(ProjectBaseSettings):
# Fast API Settings
root_path: str = Field("", examples=["/api/v2", ""])
project_name: str = Field("{{ cookiecutter.project_slug }}")
debug: bool = Field(False)
# Security Settings
secret_key: str = Field("CHANGE_ME--8^&gnoqen9+&9usjpjnsw*lhfqnl45p!^hdvf*s*i--INSECURE")
token_expiration_days: int = Field(1)
cors_origins: Annotated[list[AnyUrl] | str, BeforeValidator(parse_cors)] = []
# Service values
environment: Environment = Field(Environment.local, examples=[_ for _ in Environment])
log_level: LogLevel = Field(LogLevel.info, examples=[_ for _ in LogLevel])
# Background task config
redis_url: RedisDsn = Field(RedisDsn(url="redis://redis:6379"))
database_url: str = Field("psql://{{ cookiecutter.project_slug }}:{{ cookiecutter.project_slug }}@postgres:5432/{{ cookiecutter.project_slug }}")
# Various
timezone: str = Field(
"Europe/Riga",
examples=["UTC", "Europe/Riga", "Europe/London", "US/Pacific"],
)
sentry_url: HttpUrl | None = Field(None)