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