mirror of
https://github.com/fastapi-users/fastapi-users.git
synced 2026-03-13 07:49:55 +08:00
Fix #842: remove Database reference from SQLAlchemy app.py
This commit is contained in:
@@ -1,6 +1,5 @@
|
||||
from fastapi import Depends, FastAPI
|
||||
|
||||
from app.db import database
|
||||
from app.models import UserDB
|
||||
from app.users import auth_backend, current_active_user, fastapi_users
|
||||
|
||||
@@ -26,13 +25,3 @@ app.include_router(fastapi_users.get_users_router(), prefix="/users", tags=["use
|
||||
@app.get("/authenticated-route")
|
||||
async def authenticated_route(user: UserDB = Depends(current_active_user)):
|
||||
return {"message": f"Hello {user.email}!"}
|
||||
|
||||
|
||||
@app.on_event("startup")
|
||||
async def startup():
|
||||
await database.connect()
|
||||
|
||||
|
||||
@app.on_event("shutdown")
|
||||
async def shutdown():
|
||||
await database.disconnect()
|
||||
|
||||
Reference in New Issue
Block a user