Moved code to subfolder
This commit is contained in:
1
backend/config/__init__.py
Normal file
1
backend/config/__init__.py
Normal file
@@ -0,0 +1 @@
|
||||
from .config import Settings
|
23
backend/config/config.py
Normal file
23
backend/config/config.py
Normal file
@@ -0,0 +1,23 @@
|
||||
from beanie import init_beanie
|
||||
from motor.motor_asyncio import AsyncIOMotorClient
|
||||
from pydantic import BaseSettings
|
||||
from typing import Literal
|
||||
|
||||
from models.request import Request
|
||||
|
||||
|
||||
class Settings(BaseSettings):
|
||||
DATABASE_URL: str
|
||||
AZURE_KEY: str
|
||||
AZURE_ENDPOINT: str
|
||||
AZURE_LOCATION: str
|
||||
ENV: Literal["dev", "prod"]
|
||||
|
||||
class Config:
|
||||
env_file = ".env"
|
||||
orm_mode = True
|
||||
|
||||
|
||||
async def initiate_database():
|
||||
client = AsyncIOMotorClient(Settings().DATABASE_URL)
|
||||
await init_beanie(database=client.get_default_database(), document_models=[Request])
|
Reference in New Issue
Block a user