rumine-api-wrapper/app/app.py

24 lines
584 B
Python
Raw Normal View History

2024-03-07 14:06:53 +01:00
from typing import Tuple
from fastapi import FastAPI
from pydantic import MySQLDsn
from config import configs
from db import MySQLConfig, Database
def get_app() -> FastAPI:
app = FastAPI()
return app
def get_config(url: MySQLDsn) -> MySQLConfig:
db_config = MySQLConfig(url=url)
return db_config
def get_database(uri: MySQLConfig) -> Database:
database = Database(uri=uri)
return database
def init_app() -> Tuple[FastAPI, Database]:
app = get_app()
uri = get_config(url=configs.DB_URI)
database = get_database(uri=uri)
return app, database