auth and raw sql in alchemy

This commit is contained in:
2024-04-01 09:19:10 +00:00
parent 4e6aee8c3a
commit 949ea9fdcf
19 changed files with 71 additions and 40 deletions

View File

@@ -1,16 +1,15 @@
from fastapi import FastAPI
from sqlalchemy.ext.asyncio import AsyncEngine, AsyncSession, async_sessionmaker
from sqlalchemy.ext.asyncio import (AsyncEngine, AsyncSession,
async_sessionmaker)
from api.application.abstractions.uow import UnitOfWork
from api.application.protocols.password_hasher import PasswordHasher
from api.application.usecase.user.create_user import CreateUser
from api.application.usecase.auth.create_user import CreateUser
from api.domain.user.repository import UserRepository
from api.infrastructure.dependencies.adapters import (
create_engine,
create_session_maker,
new_session,
new_unit_of_work,
)
from api.infrastructure.dependencies.adapters import (create_engine,
create_session_maker,
new_session,
new_unit_of_work)
from api.infrastructure.dependencies.configs import app_settings
from api.infrastructure.dependencies.protocols import get_password_hasher
from api.infrastructure.dependencies.repositories import get_user_repository

View File

@@ -21,6 +21,7 @@ async def lifespan(app: FastAPI) -> AsyncGenerator:
engine = app.dependency_overrides[AsyncEngine](app.dependency_overrides[Settings]())
async with engine.begin() as conn:
await conn.run_sync(Base.metadata.drop_all)
await conn.run_sync(Base.metadata.create_all)
yield

View File

@@ -1,8 +1,10 @@
from fastapi import FastAPI
from api.presentation.routers import healthcheck_router, user_router
from api.presentation.routers import (auth_router, healthcheck_router,
user_router)
def init_routers(app: FastAPI) -> None:
app.include_router(user_router)
app.include_router(auth_router)
app.include_router(healthcheck_router)