feat(market): add CoinGecko market data panel with cached /api/market endpoint

This commit is contained in:
2026-03-09 17:55:24 +01:00
parent 3aaa6707c5
commit 1f86a5ead4
10 changed files with 521 additions and 12 deletions

29
lib/market.ts Normal file
View File

@@ -0,0 +1,29 @@
import { z } from "zod";
export interface CryptoMarketResponse {
code: string;
name: string;
priceUsd: number;
change24hPct: number | null;
marketCapUsd: number | null;
volume24hUsd: number | null;
updatedAt: string;
source: string;
}
const marketResponseSchema = z.object({
code: z.string(),
name: z.string(),
priceUsd: z.number().positive(),
change24hPct: z.number().nullable(),
marketCapUsd: z.number().nullable(),
volume24hUsd: z.number().nullable(),
updatedAt: z.string(),
source: z.string(),
});
export function parseCryptoMarketResponse(
payload: unknown,
): CryptoMarketResponse {
return marketResponseSchema.parse(payload);
}