From d73c7ef2bcbc1c877f2a15929bf4c73631a101fd Mon Sep 17 00:00:00 2001 From: bender Date: Tue, 12 May 2026 22:50:01 +0000 Subject: [PATCH] Add src/lib/teemdrop-api.ts --- src/lib/teemdrop-api.ts | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 src/lib/teemdrop-api.ts diff --git a/src/lib/teemdrop-api.ts b/src/lib/teemdrop-api.ts new file mode 100644 index 0000000..55bd8d1 --- /dev/null +++ b/src/lib/teemdrop-api.ts @@ -0,0 +1,24 @@ +const TEEMDROP_API_URL = process.env.NEXT_PUBLIC_TEEMDROP_API_URL || 'https://api.teemdrop.com'; +const TEEMDROP_API_KEY = process.env.TEEMDROP_API_KEY; + +export const teemdropRequest = async (endpoint: string, options: RequestInit = {}) => { + const headers = { + 'Content-Type': 'application/json', + 'Authorization': `Bearer ${TEEMDROP_API_KEY}`, + ...options.headers, + }; + + const response = await fetch(`${TEEMDROP_API_URL}${endpoint}`, { + ...options, + headers, + }); + + if (!response.ok) { + throw new Error(`Teemdrop API error: ${response.statusText}`); + } + + return response.json(); +}; + +export const getProducts = () => teemdropRequest('/products'); +export const getOrderDetails = (orderId: string) => teemdropRequest(`/orders/${orderId}`); \ No newline at end of file