30 lines
769 B
TypeScript
30 lines
769 B
TypeScript
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`);
|
|
}
|
|
|
|
const { title, entries, current_entry_choices, language, status } = response.data;
|
|
|
|
return {
|
|
title: title,
|
|
entries,
|
|
choices: current_entry_choices,
|
|
language: language,
|
|
status: status
|
|
};
|
|
};
|