diff --git a/app/bindings.d.ts b/app/bindings.d.ts index 2db624c..3daf79e 100644 --- a/app/bindings.d.ts +++ b/app/bindings.d.ts @@ -5,4 +5,5 @@ declare global { const SESSION_SECRET: string; const GRAPH_JSON_API_KEY: string; const GRAPH_JSON_COLLECTION: string; + const PEEKALINK_API_KEY: string; } diff --git a/app/graphJSON.server.ts b/app/graphJSON.server.ts index ec0f047..024590f 100644 --- a/app/graphJSON.server.ts +++ b/app/graphJSON.server.ts @@ -1,4 +1,8 @@ export async function sendEvent(event: Record): Promise { + if (!GRAPH_JSON_API_KEY || !GRAPH_JSON_COLLECTION) { + return; + } + const payload = { api_key: GRAPH_JSON_API_KEY, collection: GRAPH_JSON_COLLECTION, diff --git a/app/routes/actions/getPreview.$url.ts b/app/routes/actions/getPreview.$url.ts index 3d196ac..cc9a98b 100644 --- a/app/routes/actions/getPreview.$url.ts +++ b/app/routes/actions/getPreview.$url.ts @@ -40,10 +40,14 @@ export const loader: LoaderFunction = async ({ params, request }) => { }); } + if (!PEEKALINK_API_KEY) { + return json({ error: "No preview available for this URL" }); + } + const response = await fetch("https://api.peekalink.io/", { method: "POST", headers: { - "X-API-Key": "516ec4cd-6ebd-43ce-bc6d-b0b927d79188", + "X-API-Key": PEEKALINK_API_KEY, "content-type": "application/json", }, body: JSON.stringify({ link: decoded }), diff --git a/wrangler.toml b/wrangler.toml index d1102d2..6c3b376 100644 --- a/wrangler.toml +++ b/wrangler.toml @@ -35,4 +35,5 @@ GRAPH_JSON_COLLECTION = "jsonhero-prod" # Secrets # [SESSION_STORAGE] -# [GRAPH_JSON_API_KEY] \ No newline at end of file +# [GRAPH_JSON_API_KEY] +# [PEEKALINK_API_KEY] \ No newline at end of file