rlt_salary/app/config.py

22 lines
591 B
Python
Raw Permalink Normal View History

2024-02-27 20:21:36 +01:00
from pydantic_settings import BaseSettings, SettingsConfigDict
from pydantic import computed_field, MongoDsn
from pydantic_core import Url
2024-02-27 20:21:36 +01:00
2024-02-27 23:27:42 +01:00
class Configs(BaseSettings):
2024-02-27 20:21:36 +01:00
API_TOKEN_TG: str
HOST_MONGODB: str
DATABASE_NAME: str
COLLECTION_NAME: str
USERNAME_MONGO: str
PASSWORD_MONGO: str
@computed_field
def DB_URI(self) -> MongoDsn:
return Url(
f"mongodb+srv://{self.USERNAME_MONGO}:{self.PASSWORD_MONGO}@{self.HOST_MONGODB}"
)
2024-02-27 23:27:42 +01:00
model_config = SettingsConfigDict(env_file='.env', env_file_encoding='utf-8')
configs = Configs()