seed for the first user creation

This commit is contained in:
2026-09-02 14:42:48 +03:00
parent 230dd5201b
commit 6a36b468e5
2 changed files with 43 additions and 4 deletions
+9 -3
View File
@@ -4,6 +4,7 @@ from pathlib import Path
# import uvicorn
from fastapi import FastAPI
from src.database.users.crud import Seed
from src.logging.logger import LoggingMiddleware, ProcessingTimeMiddleware
from src.web.protected_routes.auth_routes import router as protected_router
from src.web.protected_routes.protected_user_action_routes import (
@@ -14,8 +15,8 @@ from src.web.protected_routes.protected_user_action_routes import (
@asynccontextmanager
async def lifespan(app: FastAPI):
create_dirs()
await create_first_user()
yield
print("shutting down")
app=FastAPI(root_path="/", lifespan=lifespan)
@@ -30,7 +31,7 @@ async def root()->dict:
return {"root":"hello, this is root"}
def create_dirs():
def create_dirs()->None:
dirs_to_create=("./DB",
"./uploads/upload",
@@ -39,4 +40,9 @@ def create_dirs():
"./logs")
for x in dirs_to_create:
Path(x).mkdir(parents=True, exist_ok=True)
Path(x).mkdir(parents=True, exist_ok=True)
async def create_first_user()->None:
seed=Seed()
await seed.seed()