From 936a8437b7e53d3287ff01941829195477fdee77 Mon Sep 17 00:00:00 2001 From: dylan Date: Sun, 28 Dec 2025 18:14:00 +0000 Subject: [PATCH] added hardcover activity function with API key validation --- utils.js | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/utils.js b/utils.js index bb76488..2e783a8 100644 --- a/utils.js +++ b/utils.js @@ -252,8 +252,14 @@ export async function getTraktMovie(config) { // ======================================================================== // hardcover graphql api - grabs your currently reading book +// requires HARDCOVER_API_KEY see readme for more info export async function getHardcoverActivity(config) { const { userId, feedUrl } = config + const apiKey = process.env.HARDCOVER_API_KEY + if (!apiKey) { + throw new Error('HARDCOVER_API_KEY environment variable not set') + } + const query = ` query { user(username: "${userId}") { @@ -267,7 +273,10 @@ export async function getHardcoverActivity(config) { const res = await fetch(feedUrl, { method: 'POST', - headers: { 'Content-Type': 'application/json' }, + headers: { + 'Content-Type': 'application/json', + authorization: apiKey, + }, body: JSON.stringify({ query }), })