chore: cleanup

This commit is contained in:
DESKTOP-RTLN3BA\$punk 2026-01-07 19:07:06 -08:00
parent 33ab74f698
commit 48fc70a08b
22 changed files with 8 additions and 1540 deletions

View file

@ -130,44 +130,3 @@ export async function authenticatedFetch(
return response;
}
/**
* Type for the result of a fetch operation with built-in error handling
*/
export type FetchResult<T> =
| { success: true; data: T; response: Response }
| { success: false; error: string; status?: number };
/**
* Authenticated fetch with JSON response handling
* Returns a result object instead of throwing on non-401 errors
*/
export async function authenticatedFetchJson<T = unknown>(
url: string,
options?: RequestInit & { skipAuthRedirect?: boolean }
): Promise<FetchResult<T>> {
try {
const response = await authenticatedFetch(url, options);
if (!response.ok) {
const errorData = await response.json().catch(() => ({}));
return {
success: false,
error: errorData.detail || `Request failed: ${response.status}`,
status: response.status,
};
}
const data = await response.json();
return { success: true, data, response };
} catch (err: any) {
// Re-throw if it's the unauthorized redirect
if (err.message?.includes("Unauthorized")) {
throw err;
}
return {
success: false,
error: err.message || "Request failed",
};
}
}