This commit is contained in:
ValdiANS
2025-09-26 11:06:31 +07:00
parent a5524686a6
commit 2e1b0fef2b
36 changed files with 8716 additions and 79 deletions
+22
View File
@@ -0,0 +1,22 @@
export type HttpMethod = 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE';
export type AuthMode = 'none' | 'cookie' | 'bearer';
export type RequestOptions<B = unknown> = {
method?: HttpMethod;
body?: B;
query?: Record<string, unknown>;
headers?: Record<string, string>;
auth?: AuthMode; // 'cookie' | 'bearer' | 'none'
token?: string; // required if auth === 'bearer'
timeoutMs?: number;
};
export class HttpError extends Error {
constructor(
public status: number,
public code?: string,
public data?: unknown
) {
super(`HTTP ${status}${code ? ` ${code}` : ''}`);
}
}