From a2bcc1dcc17c301a08adf96aa4e28cb86f472811 Mon Sep 17 00:00:00 2001 From: John Costa Date: Mon, 30 Jun 2025 21:01:02 +0100 Subject: [PATCH] feat --- src/lib/twitch.ts | 20 ++++++++++++++++++++ src/routes/+page.ts | 8 ++++++++ 2 files changed, 28 insertions(+) create mode 100644 src/routes/+page.ts diff --git a/src/lib/twitch.ts b/src/lib/twitch.ts index 28c5ab7..b52a34f 100644 --- a/src/lib/twitch.ts +++ b/src/lib/twitch.ts @@ -38,6 +38,7 @@ export const twitchChallengeEvent = z.object({ }) }); + // Not the complete event, but the information we need. export const twitchFollowEvent = z.object({ subscription: z.object({ @@ -114,7 +115,26 @@ export const createTwitchClient = () => { console.log("Subscribe to follow: ", res); }; + const getSubscriptionStatus = async () => { + const twitchSubResponse = await fetch( + "https://api.twitch.tv/helix/eventsub/subscriptions", + { + headers: { + Authorization: `Bearer ${await _access_token}`, + "Client-Id": TWITCH_APP_CLIENT_ID, + "Content-Type": "application/json", + }, + }, + ); + + const res = await twitchSubResponse.json(); + console.log("-------------------") + console.log("Subscription status"); + console.log(res); + } + return { subscribeToFollow, + getSubscriptionStatus, }; }; diff --git a/src/routes/+page.ts b/src/routes/+page.ts new file mode 100644 index 0000000..ae69d3b --- /dev/null +++ b/src/routes/+page.ts @@ -0,0 +1,8 @@ +import { twitchClient } from "$lib"; +import type { PageLoad } from "./$types"; + +export const load: PageLoad = async ({ params }) => { + await twitchClient.getSubscriptionStatus(); + + return {}; +};