From df34bf34679fb5e4917203fc2ddb46c6ef7ad994 Mon Sep 17 00:00:00 2001 From: Cursor Agent Date: Mon, 9 Jun 2025 17:01:45 +0000 Subject: [PATCH 1/2] Changes from background composer bc-3cf67edc-580c-43f4-bc62-9ac6d11d854d --- src/hooks.server.ts | 6 +++++- src/lib/forms/UserSubmissionAction.ts | 5 +++++ src/routes/(blank)/og/[show_number].jpg/+server.ts | 6 +++--- src/routes/(site)/snackpack/+page.server.ts | 4 ++++ src/routes/api/oauth/github/+server.ts | 9 ++++++++- src/routes/robots.txt/+server.ts | 8 ++++++-- src/routes/sitemap.xml/+server.ts | 5 ++++- src/server/auth/access_token.ts | 13 +++++++++++-- src/server/video/youtube_api.ts | 10 +++++++++- 9 files changed, 55 insertions(+), 11 deletions(-) diff --git a/src/hooks.server.ts b/src/hooks.server.ts index 3928b3819..aa4f6d499 100644 --- a/src/hooks.server.ts +++ b/src/hooks.server.ts @@ -9,11 +9,15 @@ import { prisma_client } from '$/server/prisma-client'; import { find_user_by_access_token } from './server/auth/users'; // import { dev } from '$app/environment'; import { dev } from '$app/environment'; -import { UPSPLASH_TOKEN, UPSPLASH_URL } from '$env/static/private'; +import { env } from '$env/dynamic/private'; import get_show_path from '$utilities/slug'; import { Redis } from '@upstash/redis'; import { nodeProfilingIntegration } from '@sentry/profiling-node'; +// Safely access environment variables +const UPSPLASH_TOKEN = env.UPSPLASH_TOKEN; +const UPSPLASH_URL = env.UPSPLASH_URL; + export const cache_status = UPSPLASH_URL && UPSPLASH_TOKEN ? 'ONLINE' : 'OFFLINE'; export const redis = diff --git a/src/lib/forms/UserSubmissionAction.ts b/src/lib/forms/UserSubmissionAction.ts index 7f66f14ff..9f0df4474 100644 --- a/src/lib/forms/UserSubmissionAction.ts +++ b/src/lib/forms/UserSubmissionAction.ts @@ -6,6 +6,11 @@ import { user_submission_schema } from '$/lib/forms/userSubmissionSchema'; import { z } from 'zod'; export const user_submission_action: Action = async function ({ locals }) { + // Check if TURNSTILE_SECRET is available + if (!env.TURNSTILE_SECRET) { + return fail(400, { message: 'Server configuration error', error: 'Missing TURNSTILE_SECRET' }); + } + // Validate Turnsile Token let { error } = await validateToken( locals.form_data['cf-turnstile-response'], diff --git a/src/routes/(blank)/og/[show_number].jpg/+server.ts b/src/routes/(blank)/og/[show_number].jpg/+server.ts index 0d1323bc2..a3ac3fb3f 100644 --- a/src/routes/(blank)/og/[show_number].jpg/+server.ts +++ b/src/routes/(blank)/og/[show_number].jpg/+server.ts @@ -1,6 +1,6 @@ import { dev } from '$app/environment'; import chrome from '@sparticuz/chromium'; -import puppeteer, { Browser, type Product } from 'puppeteer-core'; +import puppeteer, { Browser } from 'puppeteer-core'; import { redis } from '$/hooks.server.js'; const exePath = '/Applications/Google Chrome.app/Contents/MacOS/Google Chrome'; @@ -9,14 +9,14 @@ chrome.setGraphicsMode = true; async function getOptions() { if (dev) { return { - product: 'chrome' as Product, + product: 'chrome' as const, args: [], executablePath: exePath, headless: true }; } return { - product: 'chrome' as Product, + product: 'chrome' as const, args: chrome.args, executablePath: await chrome.executablePath(), headless: !!chrome.headless diff --git a/src/routes/(site)/snackpack/+page.server.ts b/src/routes/(site)/snackpack/+page.server.ts index 139e39c1a..7e33ac675 100644 --- a/src/routes/(site)/snackpack/+page.server.ts +++ b/src/routes/(site)/snackpack/+page.server.ts @@ -41,6 +41,10 @@ type BroadCastResponse = { }; async function getBroadcastsPage(after?: string) { + if (!env.CONVERT_KIT_V4_API_KEY) { + throw new Error('CONVERT_KIT_V4_API_KEY is not defined'); + } + const params = new URLSearchParams(); if (after) { params.append('after', after); diff --git a/src/routes/api/oauth/github/+server.ts b/src/routes/api/oauth/github/+server.ts index 74861e9fb..abf34a34a 100644 --- a/src/routes/api/oauth/github/+server.ts +++ b/src/routes/api/oauth/github/+server.ts @@ -1,10 +1,17 @@ import { randomUUID } from 'crypto'; import { GITHUB_AUTH_URL } from '$const'; -import { PUBLIC_GITHUB_ID } from '$env/static/public'; +import { env } from '$env/dynamic/public'; import type { RequestHandler } from '@sveltejs/kit'; import { prisma_client } from '$/server/prisma-client'; +// Safely access environment variable +const PUBLIC_GITHUB_ID = env.PUBLIC_GITHUB_ID; + export const GET: RequestHandler = async function ({ locals, cookies }) { + if (!PUBLIC_GITHUB_ID) { + return new Response('GitHub OAuth not configured', { status: 500 }); + } + const access_token = cookies.get('access_token'); if (!access_token) { diff --git a/src/routes/robots.txt/+server.ts b/src/routes/robots.txt/+server.ts index 4d85af280..3e5342033 100644 --- a/src/routes/robots.txt/+server.ts +++ b/src/routes/robots.txt/+server.ts @@ -1,13 +1,17 @@ import type { RequestHandler } from '@sveltejs/kit'; -import { PUBLIC_URL } from '$env/static/public'; +import { env } from '$env/dynamic/public'; + +// Safely access environment variable +const PUBLIC_URL = env.PUBLIC_URL; export const GET: RequestHandler = async function GET({ setHeaders }) { + const baseUrl = PUBLIC_URL || 'syntax.fm'; const robotsTxt = `User-agent: * Disallow: /admin Disallow: /haters Disallow: /api -Sitemap: https://${PUBLIC_URL}/sitemap.xml`; +Sitemap: https://${baseUrl}/sitemap.xml`; setHeaders({ 'cache-control': 'max-age=0, s-maxage=3600', diff --git a/src/routes/sitemap.xml/+server.ts b/src/routes/sitemap.xml/+server.ts index 3b0d35178..a55c29861 100644 --- a/src/routes/sitemap.xml/+server.ts +++ b/src/routes/sitemap.xml/+server.ts @@ -1,7 +1,10 @@ import type { RequestHandler } from '@sveltejs/kit'; -import { PUBLIC_URL } from '$env/static/public'; +import { env } from '$env/dynamic/public'; import { prisma_client } from '$/server/prisma-client'; +// Safely access environment variable +const PUBLIC_URL = env.PUBLIC_URL; + const site = `https://${PUBLIC_URL}`; export const GET: RequestHandler = async function GET({ setHeaders }) { diff --git a/src/server/auth/access_token.ts b/src/server/auth/access_token.ts index 57393f59d..c359639ef 100644 --- a/src/server/auth/access_token.ts +++ b/src/server/auth/access_token.ts @@ -1,8 +1,17 @@ -import { PUBLIC_GITHUB_ID } from '$env/static/public'; -import { GH_SECRET } from '$env/static/private'; +import { env as publicEnv } from '$env/dynamic/public'; +import { env as privateEnv } from '$env/dynamic/private'; + +// Safely access environment variables +const PUBLIC_GITHUB_ID = publicEnv.PUBLIC_GITHUB_ID; +const GH_SECRET = privateEnv.GH_SECRET; + const tokenURL = 'https://github.com/login/oauth/access_token'; export async function get_access_token(code: string): Promise { + if (!PUBLIC_GITHUB_ID || !GH_SECRET) { + throw new Error('GitHub OAuth environment variables not configured'); + } + try { const response = await fetch(tokenURL, { method: 'POST', diff --git a/src/server/video/youtube_api.ts b/src/server/video/youtube_api.ts index 359d33e18..78e7fe1a1 100644 --- a/src/server/video/youtube_api.ts +++ b/src/server/video/youtube_api.ts @@ -1,8 +1,11 @@ import { YOUTUBE_CHANNEL_ID } from '$/const'; import { prisma_client } from '$/server/prisma-client'; -import { YOUTUBE_API_KEY } from '$env/static/private'; +import { env } from '$env/dynamic/private'; import slug from 'speakingurl'; +// Safely access environment variable +const YOUTUBE_API_KEY = env.YOUTUBE_API_KEY; + // Youtube importer // Important things to know -> Youtube is the source of truth for all the data // If you want to update something, update it on youtube and manually re-sync or wait for the auto sync to run @@ -50,6 +53,11 @@ interface YouTubePlaylistItemResponse { } export async function get_remote_playlists(): Promise { + if (!YOUTUBE_API_KEY) { + console.error('YOUTUBE_API_KEY is not defined'); + return; + } + const base_url = 'https://www.googleapis.com/youtube/v3/playlists'; const params = new URLSearchParams({ part: 'snippet,contentDetails', From 826563c1b75c5dda9a835a0ed4c635e7f848c88e Mon Sep 17 00:00:00 2001 From: Cursor Agent Date: Mon, 9 Jun 2025 17:04:27 +0000 Subject: [PATCH 2/2] Update schedule text to reflect twice weekly service frequency --- src/lib/schedule.svelte | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lib/schedule.svelte b/src/lib/schedule.svelte index 863d8ec6e..7c4bc0d86 100644 --- a/src/lib/schedule.svelte +++ b/src/lib/schedule.svelte @@ -1,5 +1,5 @@
-

Served Fresh Thrice Weekly

+

Served Fresh Twice Weekly

15m

Monday