18 lines
634 B
TypeScript
18 lines
634 B
TypeScript
|
|
import { error, type ServerLoad } from '@sveltejs/kit';
|
||
|
|
import { getJobApiJobsJobIdGet } from '../../../../client/sdk.gen.ts';
|
||
|
|
import { PUBLIC_API_BASE_URL } from '$env/static/public';
|
||
|
|
|
||
|
|
export const load: ServerLoad = async ({ params, locals }) => {
|
||
|
|
const { data, response } = await getJobApiJobsJobIdGet({
|
||
|
|
headers: { Authorization: `Bearer ${locals.authToken ?? ''}` },
|
||
|
|
path: { job_id: params.job_id }
|
||
|
|
});
|
||
|
|
|
||
|
|
if (!data || response.status !== 200) {
|
||
|
|
error(response.status === 404 ? 404 : 500, 'Job not found');
|
||
|
|
}
|
||
|
|
|
||
|
|
const fullAudioUrl = `${PUBLIC_API_BASE_URL}/media/${data.audio_url}`;
|
||
|
|
return { job: data, fullAudioUrl };
|
||
|
|
};
|