Files
nwxraybot/nwxraybot/config.py
Sergey Elpashev d2704d43b8
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
ci/woodpecker/manual/woodpecker Pipeline was successful
Feat: move from stack to compose
2024-12-28 09:35:10 +03:00

23 lines
876 B
Python

from pydantic import Field, SecretStr
from pydantic_settings import BaseSettings, SettingsConfigDict
class Settings(BaseSettings):
bot_token: SecretStr = Field('token', env="BOT_TOKEN")
debug: bool = Field(False, env="DEBUG")
postgres_user: str = Field('user', env="POSTGRES_USER")
postgres_password: SecretStr = Field('password', env="POSTGRES_PASSWORD")
postgres_db: str = Field('db', env="POSTGRES_DB")
postgres_host: str = Field('localhost', env="POSTGRES_HOST")
postgres_port: int = Field(5432, env="POSTGRES_PORT")
@property
def postgres_url(self) -> str:
return f"postgresql://{self.postgres_user}:{
self.postgres_password.get_secret_value()}@{self.postgres_host}:{self.postgres_port}/{self.postgres_db}"
class Config:
env_file = ".env"
env_file_encoding = "utf-8"
extra = "allow"