No longer hard-coding the peekalink API key

This commit is contained in:
Eric Allam
2022-03-02 10:53:13 +00:00
parent b749d2ab80
commit b2bca35e84
4 changed files with 12 additions and 2 deletions
+1
View File
@@ -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;
}
+4
View File
@@ -1,4 +1,8 @@
export async function sendEvent(event: Record<string, any>): Promise<void> {
if (!GRAPH_JSON_API_KEY || !GRAPH_JSON_COLLECTION) {
return;
}
const payload = {
api_key: GRAPH_JSON_API_KEY,
collection: GRAPH_JSON_COLLECTION,
+5 -1
View File
@@ -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 }),
+1
View File
@@ -36,3 +36,4 @@ GRAPH_JSON_COLLECTION = "jsonhero-prod"
# Secrets
# [SESSION_STORAGE]
# [GRAPH_JSON_API_KEY]
# [PEEKALINK_API_KEY]