Fix more bugs
This commit is contained in:
parent
868929e9f2
commit
b0638f195a
gateway/src/api
|
@ -1,3 +1,3 @@
|
|||
API_USERS = "http://fids_usermanager_api:5000/users/"
|
||||
API_FLIGHTS = "http://fids_flights_api:5000/flights/"
|
||||
API_AUTH = "http://fids_usermanager_api:5000/auth/"
|
||||
API_USERS = "http://fids_usermanager_api:5000/users"
|
||||
API_FLIGHTS = "http://fids_flights_api:5000/flights"
|
||||
API_AUTH = "http://fids_usermanager_api:5000/auth"
|
||||
|
|
|
@ -13,7 +13,7 @@ router = APIRouter()
|
|||
@router.post("/register", response_model=UserMin)
|
||||
async def register(user: UserRegister):
|
||||
(response, status, _) = await request(
|
||||
f"{API_AUTH}register", "POST", json=user.model_dump()
|
||||
f"{API_AUTH}/register", "POST", json=user.model_dump()
|
||||
)
|
||||
if status < 200 or status > 204:
|
||||
raise HTTPException(status_code=status, detail=response)
|
||||
|
@ -23,7 +23,7 @@ async def register(user: UserRegister):
|
|||
@router.post("/login", response_model=Token)
|
||||
async def login(user: UserLogin):
|
||||
(response, status, _) = await request(
|
||||
f"{API_AUTH}login", "POST", json=user.model_dump()
|
||||
f"{API_AUTH}/login", "POST", json=user.model_dump()
|
||||
)
|
||||
if status < 200 or status > 204:
|
||||
raise HTTPException(status_code=status, detail=response)
|
||||
|
@ -33,7 +33,7 @@ async def login(user: UserLogin):
|
|||
@router.post("/refresh", response_model=Token)
|
||||
async def refresh(token: RefreshToken):
|
||||
(response, status, _) = await request(
|
||||
f"{API_AUTH}refresh", "POST", json=token.model_dump()
|
||||
f"{API_AUTH}/refresh", "POST", json=token.model_dump()
|
||||
)
|
||||
if status < 200 or status > 204:
|
||||
raise HTTPException(status_code=status, detail=response)
|
||||
|
@ -43,7 +43,7 @@ async def refresh(token: RefreshToken):
|
|||
@router.get("/status", response_model=UserMin)
|
||||
async def status(authorization: Annotated[str | None, Header()] = None):
|
||||
header = {"Authorization": authorization if authorization is not None else ""}
|
||||
(response, status, _) = await request(f"{API_AUTH}status", "GET", headers=header)
|
||||
(response, status, _) = await request(f"{API_AUTH}/status", "GET", headers=header)
|
||||
if status < 200 or status > 204:
|
||||
raise HTTPException(status_code=status, detail=response)
|
||||
return response
|
||||
|
|
|
@ -12,7 +12,7 @@ router = APIRouter()
|
|||
|
||||
@router.get("/{id}", response_model=Flight)
|
||||
async def get_flight_by_id(id: int):
|
||||
(response, status, _) = await request(f"{API_FLIGHTS}{id}", "GET")
|
||||
(response, status, _) = await request(f"{API_FLIGHTS}/{id}", "GET")
|
||||
if status < 200 or status > 204:
|
||||
raise HTTPException(status_code=status, detail=response)
|
||||
return response
|
||||
|
@ -39,7 +39,7 @@ async def update_flight(
|
|||
):
|
||||
await checkAuth(authorization)
|
||||
(response, status, _) = await request(
|
||||
f"{API_FLIGHTS}{id}", "PATCH", json=status_update.model_dump()
|
||||
f"{API_FLIGHTS}/{id}", "PATCH", json=status_update.model_dump()
|
||||
)
|
||||
if status < 200 or status > 204:
|
||||
raise HTTPException(status_code=status, detail=response)
|
||||
|
@ -53,7 +53,7 @@ async def get_flights(origin: Optional[str] = None, lastUpdated: Optional[str] =
|
|||
query["origin"] = origin
|
||||
if lastUpdated:
|
||||
query["lastUpdated"] = lastUpdated
|
||||
(response, status, _) = await request(f"{API_FLIGHTS}", "GET", query=lastUpdated)
|
||||
(response, status, _) = await request(f"{API_FLIGHTS}", "GET", query=query)
|
||||
if status < 200 or status > 204:
|
||||
raise HTTPException(status_code=status, detail=response)
|
||||
return response
|
||||
|
|
|
@ -27,7 +27,7 @@ async def create_users(user: UserRegister):
|
|||
|
||||
@router.get("/{id}", response_model=User)
|
||||
async def get_user(id: str):
|
||||
(response, status, _) = await request(f"{API_USERS}{id}", "GET")
|
||||
(response, status, _) = await request(f"{API_USERS}/{id}", "GET")
|
||||
if status < 200 or status > 204:
|
||||
raise HTTPException(status_code=status, detail=response)
|
||||
return response
|
||||
|
@ -36,7 +36,7 @@ async def get_user(id: str):
|
|||
@router.put("/{id}", response_model=User)
|
||||
async def update_user(user: UserRegister):
|
||||
(response, status, _) = await request(
|
||||
f"{API_USERS}{id}", "PUT", json=user.model_dump()
|
||||
f"{API_USERS}/{id}", "PUT", json=user.model_dump()
|
||||
)
|
||||
if status < 200 or status > 204:
|
||||
raise HTTPException(status_code=status, detail=response)
|
||||
|
@ -45,7 +45,7 @@ async def update_user(user: UserRegister):
|
|||
|
||||
@router.delete("/{id}", response_model=User)
|
||||
async def delete_user():
|
||||
(response, status, _) = await request(f"{API_USERS}{id}", "DELETE")
|
||||
(response, status, _) = await request(f"{API_USERS}/{id}", "DELETE")
|
||||
if status < 200 or status > 204:
|
||||
raise HTTPException(status_code=status, detail=response)
|
||||
return response
|
||||
|
|
Loading…
Reference in New Issue