mirror of
https://github.com/dat515-2025/Group-8.git
synced 2026-03-22 15:12:08 +01:00
feat(infrastructure): add basic project deployment
This commit is contained in:
@@ -1,11 +1,24 @@
|
||||
from fastapi import Depends, FastAPI
|
||||
from fastapi.middleware.cors import CORSMiddleware
|
||||
|
||||
from .db import User, create_db_and_tables
|
||||
from .schemas import UserCreate, UserRead, UserUpdate
|
||||
from .users import auth_backend, current_active_user, fastapi_users
|
||||
from .users import auth_backend, current_active_verified_user, fastapi_users
|
||||
|
||||
app = FastAPI()
|
||||
|
||||
# CORS for frontend dev server
|
||||
app.add_middleware(
|
||||
CORSMiddleware,
|
||||
allow_origins=[
|
||||
"http://localhost:5173",
|
||||
"http://127.0.0.1:5173",
|
||||
],
|
||||
allow_credentials=True,
|
||||
allow_methods=["*"],
|
||||
allow_headers=["*"],
|
||||
)
|
||||
|
||||
app.include_router(
|
||||
fastapi_users.get_auth_router(auth_backend), prefix="/auth/jwt", tags=["auth"]
|
||||
)
|
||||
@@ -32,7 +45,7 @@ app.include_router(
|
||||
|
||||
|
||||
@app.get("/authenticated-route")
|
||||
async def authenticated_route(user: User = Depends(current_active_user)):
|
||||
async def authenticated_route(user: User = Depends(current_active_verified_user)):
|
||||
return {"message": f"Hello {user.email}!"}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user