StaffLDB-Minify #1

Merged
fred.boniface merged 27 commits from StaffLDB-Minify into main 2023-10-03 21:37:00 +01:00
2 changed files with 31 additions and 33 deletions
Showing only changes of commit 86b072f387 - Show all commits

View File

@ -1,38 +1,36 @@
<script lang="ts">
import { uuid } from '$lib/stores/uuid';
import { getApiUrl } from '$lib/scripts/upstream';
import type { ApiResponse, StaffLdb } from '@owlboard/ts-types';
import { uuid } from "$lib/stores/uuid";
import { getApiUrl } from "$lib/scripts/upstream";
import type { ApiResponse, StaffLdb } from "@owlboard/ts-types";
export let station: string;
export let title: string | undefined = 'Loading...';
export let station: string
export let title: string | undefined = "Loading..."
const fetchUrl = getApiUrl();
const fetchUrl = getApiUrl();
async function fetchStaffLdb(station: string) {
const url = `${fetchUrl}/api/v2/live/station/${station}/staff`
const options = {
method: 'GET',
headers: {
uuid: $uuid,
},
async function fetchStaffLdb(station: string) {
const url = `${fetchUrl}/api/v2/live/station/${station}/staff`;
const options = {
method: 'GET',
headers: {
uuid: $uuid
}
};
const res = await fetch(url, options);
let jsonData: ApiResponse<StaffLdb>;
if (res.status === 200) {
jsonData = await res.json();
title = jsonData.data?.locationName;
} else if (res.status === 401) {
console.log(`Request Status: ${res.status}`);
title = 'Unauthorised';
}
}
const res = await fetch(url, options)
let jsonData: ApiResponse<StaffLdb>
if (res.status === 200) {
jsonData = await res.json()
title = jsonData.data?.locationName
} else if (res.status === 401) {
console.log(`Request Status: ${res.status}`)
title = "Unauthorised"
}
}
</script>
{#await fetchStaffLdb(station)}
Loading
{:then data}
{:then data}
Loaded {JSON.stringify(data)}
{:catch}
Error Loading

View File

@ -1,9 +1,9 @@
import { dev } from "$app/environment";
import { dev } from '$app/environment';
export function getApiUrl() {
if (dev) {
console.info("DEVMODE active, using testing URL")
return "https://testing.owlboard.info"
}
return "https://owlboard.info"
}
if (dev) {
console.info('DEVMODE active, using testing URL');
return 'https://testing.owlboard.info';
}
return 'https://owlboard.info';
}