feat(web): pending-message orchestrator (TTL discard, deferred send, online retry)

This commit is contained in:
Jannis Braun
2026-05-02 16:00:30 +02:00
parent b01ad4edb8
commit 5128a625b8
6 changed files with 206 additions and 2 deletions
+11 -2
View File
@@ -78,6 +78,15 @@ export class RateLimitError extends Error {
}
}
export class HttpError extends Error {
readonly status: number;
constructor(status: number, message: string) {
super(message);
this.name = 'HttpError';
this.status = status;
}
}
export class BackspaceApiClient {
readonly auth: {
register: (data: RegisterRequest) => Promise<AuthResponse>;
@@ -316,7 +325,7 @@ export class BackspaceApiClient {
throw new RateLimitError(retryAfter);
}
const error = await response.json().catch(() => ({ error: 'Request failed' }));
throw new Error((error as { error: string }).error || `HTTP ${response.status}`);
throw new HttpError(response.status, (error as { error: string }).error || `HTTP ${response.status}`);
}
return response.json() as Promise<T>;
@@ -363,7 +372,7 @@ export class BackspaceApiClient {
throw new RateLimitError(retryAfter);
}
const error = await response.json().catch(() => ({ error: 'Upload failed' }));
throw new Error((error as { error: string }).error || `HTTP ${response.status}`);
throw new HttpError(response.status, (error as { error: string }).error || `HTTP ${response.status}`);
}
return response.json() as Promise<Attachment>;