2024-02-27 20:21:36 +01:00
|
|
|
from pydantic_settings import BaseSettings, SettingsConfigDict
|
2024-02-27 20:37:51 +01:00
|
|
|
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
|
2024-02-27 20:37:51 +01:00
|
|
|
|
|
|
|
@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()
|