2024-07-13 17:56:34 +00:00
|
|
|
from pydantic import BaseModel
|
|
|
|
from pydantic import PostgresDsn
|
|
|
|
|
|
|
|
# from pydantic import MariaDBDsn
|
|
|
|
# from pydantic import MySQLDsn
|
|
|
|
from pydantic_settings import (
|
|
|
|
BaseSettings,
|
|
|
|
SettingsConfigDict,
|
|
|
|
)
|
2024-08-06 07:05:03 +00:00
|
|
|
from pathlib import Path
|
2024-07-13 17:56:34 +00:00
|
|
|
|
|
|
|
|
2024-08-06 07:05:03 +00:00
|
|
|
BASE_DIR = Path(__file__).parent
|
|
|
|
|
2024-07-13 17:56:34 +00:00
|
|
|
class RunConfig(BaseModel):
|
|
|
|
host: str = "0.0.0.0"
|
|
|
|
port: int = 8000
|
|
|
|
reload: bool = True
|
|
|
|
|
|
|
|
|
|
|
|
class ApiPrefix(BaseModel):
|
|
|
|
users: str = "/api/users"
|
|
|
|
isp: str = "/api/isp"
|
|
|
|
isp_connections: str = "/api/isp_connections"
|
|
|
|
|
|
|
|
|
|
|
|
class WebPrefix(BaseModel):
|
|
|
|
isp: str = "/web/isp"
|
2024-07-14 18:37:00 +00:00
|
|
|
settings: str = "/web/settings"
|
2024-07-13 17:56:34 +00:00
|
|
|
isp_connections: str = "/web/isp_connections"
|
2024-07-14 18:37:00 +00:00
|
|
|
start: str = "/web"
|
2024-07-13 17:56:34 +00:00
|
|
|
|
|
|
|
|
|
|
|
class DatabaseConfig(BaseModel):
|
|
|
|
url: PostgresDsn
|
|
|
|
echo: bool = False
|
|
|
|
echo_pool: bool = False
|
|
|
|
pool_size: int = 50
|
|
|
|
max_overflow: int = 10
|
|
|
|
|
|
|
|
naming_convention: dict[str, str] = {
|
|
|
|
"ix": "ix_%(column_0_label)s",
|
|
|
|
"uq": "uq_%(table_name)s_%(column_0_N_name)s",
|
|
|
|
"ck": "ck_%(table_name)s_%(constraint_name)s",
|
|
|
|
"fk": "fk_%(table_name)s_%(column_0_name)s_%(referred_table_name)s",
|
|
|
|
"pk": "pk_%(table_name)s",
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
class Settings(BaseSettings):
|
|
|
|
model_config = SettingsConfigDict(
|
2024-08-06 07:05:03 +00:00
|
|
|
env_file=(BASE_DIR / ".env-template", BASE_DIR / ".env"),
|
2024-07-13 17:56:34 +00:00
|
|
|
case_sensitive=False,
|
|
|
|
env_nested_delimiter="__",
|
|
|
|
env_prefix="SIPI_CONFIG__",
|
|
|
|
)
|
|
|
|
run: RunConfig = RunConfig()
|
|
|
|
api: ApiPrefix = ApiPrefix()
|
|
|
|
web: WebPrefix = WebPrefix()
|
|
|
|
db: DatabaseConfig
|
|
|
|
|
|
|
|
|
|
|
|
settings = Settings()
|