Skip to content

Commit ebf31b4

Browse files
committed
Add USE_2025 constant
1 parent 4f73e5c commit ebf31b4

File tree

1 file changed

+13
-5
lines changed

1 file changed

+13
-5
lines changed

src/app/conf/2025/_data.ts

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,16 @@ import { stripHtml } from "string-strip-html"
33
import { SchedSpeaker, ScheduleSession } from "@/app/conf/2023/types"
44
import pLimit from "p-limit"
55

6+
const USE_2025 = false
7+
8+
const apiUrl = USE_2025
9+
? "https://graphqlconf2025.sched.com/api"
10+
: "https://graphqlconf2024.sched.com/api"
11+
12+
const token = USE_2025
13+
? process.env.SCHED_ACCESS_TOKEN_2025
14+
: process.env.SCHED_ACCESS_TOKEN_2024
15+
616
async function fetchData<T>(url: string): Promise<T> {
717
try {
818
const response = await fetch(url, {
@@ -21,11 +31,9 @@ async function fetchData<T>(url: string): Promise<T> {
2131
}
2232
}
2333

24-
const token = process.env.SCHED_ACCESS_TOKEN_2024
25-
2634
async function getUsernames(): Promise<string[]> {
2735
const response = await fetchData<{ username: string }[]>(
28-
`https://graphqlconf2024.sched.com/api/user/list?api_key=${token}&format=json&fields=username`,
36+
`${apiUrl}/user/list?api_key=${token}&format=json&fields=username`,
2937
)
3038
return response.map(user => user.username)
3139
}
@@ -39,7 +47,7 @@ async function getSpeakers(): Promise<SchedSpeaker[]> {
3947
usernames.map(username =>
4048
limit(() => {
4149
return fetchData<SchedSpeaker>(
42-
`https://graphqlconf2024.sched.com/api/user/get?api_key=${token}&by=username&term=${username}&format=json&fields=username,company,position,name,about,location,url,avatar,role,socialurls`,
50+
`${apiUrl}/user/get?api_key=${token}&by=username&term=${username}&format=json&fields=username,company,position,name,about,location,url,avatar,role,socialurls`,
4351
)
4452
}),
4553
),
@@ -59,7 +67,7 @@ async function getSpeakers(): Promise<SchedSpeaker[]> {
5967

6068
async function getSchedule(): Promise<ScheduleSession[]> {
6169
const sessions = await fetchData<ScheduleSession[]>(
62-
`https://graphqlconf2024.sched.com/api/session/export?api_key=${token}&format=json`,
70+
`${apiUrl}/session/export?api_key=${token}&format=json`,
6371
)
6472

6573
const result = sessions.map(session => {

0 commit comments

Comments
 (0)