2026-05-04 10:46:27 +00:00
|
|
|
import { getAdventureBffAdventureAdventureIdGet } from '@client';
|
|
|
|
|
import type { PageServerLoad } from './$types';
|
|
|
|
|
import { error } from '@sveltejs/kit';
|
|
|
|
|
|
|
|
|
|
export const load: PageServerLoad = async ({ locals, params }) => {
|
|
|
|
|
const response = await getAdventureBffAdventureAdventureIdGet({
|
|
|
|
|
path: {
|
|
|
|
|
adventure_id: params.id
|
|
|
|
|
},
|
|
|
|
|
headers: {
|
|
|
|
|
Authorization: `Bearer ${locals.authToken}`
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
if (response.error) {
|
|
|
|
|
console.error(`Error fetching an adventure:`);
|
|
|
|
|
console.error({ error: response.error });
|
|
|
|
|
return error(400, `Error loading adventure`);
|
|
|
|
|
}
|
|
|
|
|
|
2026-05-07 20:43:02 +00:00
|
|
|
const { title, entries, current_entry_choices, language } = response.data;
|
2026-05-04 10:46:27 +00:00
|
|
|
|
|
|
|
|
response.data.entries.forEach((e) => console.log(e.story_text));
|
|
|
|
|
return {
|
|
|
|
|
title: title,
|
|
|
|
|
entries,
|
2026-05-07 20:43:02 +00:00
|
|
|
choices: current_entry_choices,
|
|
|
|
|
language: language
|
2026-05-04 10:46:27 +00:00
|
|
|
};
|
|
|
|
|
};
|