Compare commits

...

4 Commits

Author SHA1 Message Date
rohitvinodmalhotra@gmail.com 6f89e444ca replace raise for status 2025-01-29 17:58:08 -05:00
rohitvinodmalhotra@gmail.com 657ff42b57 Revert "change auth route"
This reverts commit 8fa40a9499.
2025-01-29 17:08:31 -05:00
rohitvinodmalhotra@gmail.com 00a5fd7d78 let middleware handle response 2025-01-29 16:49:23 -05:00
rohitvinodmalhotra@gmail.com 8fa40a9499 change auth route 2025-01-29 13:06:00 -05:00
+16 -7
View File
@@ -52,8 +52,10 @@ async def get_github_repositories(
try:
async with httpx.AsyncClient() as client:
response = await client.get(github_api_url, headers=headers, params=params)
response.raise_for_status() # Raise an error for HTTP codes >= 400
json_response = JSONResponse(content=response.json())
json_response = JSONResponse(
content=response.json(), status_code=response.status_code
)
# Forward the Link header if it exists
if 'Link' in response.headers:
@@ -74,9 +76,9 @@ async def get_github_user(github_token: str = Depends(require_github_token)):
try:
async with httpx.AsyncClient() as client:
response = await client.get('https://api.github.com/user', headers=headers)
response.raise_for_status() # Raise an error for HTTP codes >= 400
json_response = JSONResponse(content=response.json())
json_response = JSONResponse(
content=response.json(), status_code=response.status_code
)
return json_response
except requests.exceptions.RequestException as e:
@@ -93,9 +95,16 @@ async def get_github_installation_ids(
headers = generate_github_headers(github_token)
try:
async with httpx.AsyncClient() as client:
response = await client.get('https://api.github.com/user/installations', headers=headers)
response.raise_for_status()
response = await client.get(
'https://api.github.com/user/installations', headers=headers
)
data = response.json()
if 'installations' not in data:
return JSONResponse(
content='Missing installations', status_code=response.status_code
)
ids = [installation['id'] for installation in data['installations']]
return JSONResponse(content=ids)