Development & Codecard rasterizer
High-DPI Retina • 100% In-Browser
Code to Image
Transform code snippets, terminal commands, or text into high-resolution social cards.
Presets:
Card & Editor Styling
Editor Color Theme
Backdrop Gradient
Window Frame Header
Window Title / Filename
Syntax Language
Canvas Padding48px
16 lines • 531 chars
api-client.ts
1
// High-performance API client with exponential backoff
2
export async function fetchWithRetry<T>(
3
url: string,
4
retries = 3,
5
delayMs = 1000
6
): Promise<T> {
7
try {
8
const res = await fetch(url, { headers: { "Accept": "application/json" } });
9
if (!res.ok) throw new Error(`HTTP ${res.status}: ${res.statusText}`);
10
return (await res.json()) as T;
11
} catch (err) {
12
if (retries <= 1) throw err;
13
await new Promise((r) => setTimeout(r, delayMs));
14
return fetchWithRetry<T>(url, retries - 1, delayMs * 2);
15
}
16
}
@developer