added hardcover activity function with API key validation

This commit is contained in:
dylan 2025-12-28 18:14:00 +00:00
parent 221e96b7c1
commit 936a8437b7

View file

@ -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 }),
})