From c0724d94f0a690e63c723141d23a7b38b165e21f Mon Sep 17 00:00:00 2001 From: Fred Boniface Date: Thu, 14 Sep 2023 14:07:27 +0100 Subject: [PATCH] Run Prettier --- src/lib/ldb/staff/fetch.ts | 56 +++++++++++++++--------------- src/lib/ldb/staff/staff-ldb.svelte | 2 +- 2 files changed, 29 insertions(+), 29 deletions(-) diff --git a/src/lib/ldb/staff/fetch.ts b/src/lib/ldb/staff/fetch.ts index c58ddcf..41bfafa 100644 --- a/src/lib/ldb/staff/fetch.ts +++ b/src/lib/ldb/staff/fetch.ts @@ -1,38 +1,38 @@ // Fetches StaffLDB Data, correctly formats DATE fields and returns the data -import { getApiUrl } from "$lib/scripts/upstream"; -import { uuid } from "$lib/stores/uuid"; -import type { ApiResponse, StaffLdb } from "@owlboard/ts-types"; +import { getApiUrl } from '$lib/scripts/upstream'; +import { uuid } from '$lib/stores/uuid'; +import type { ApiResponse, StaffLdb } from '@owlboard/ts-types'; // Fetch StaffLDB Data, and returns the data after hydration (convert date types etc.) export async function fetchStaffLdb(station: string): Promise> { - const url = `${getApiUrl()}/api/v2/live/station/${station}/staff`; + const url = `${getApiUrl()}/api/v2/live/station/${station}/staff`; - let uuid_value: string = ''; - const unsubscribe = uuid.subscribe((value) => { - uuid_value = value; - }); + let uuid_value: string = ''; + const unsubscribe = uuid.subscribe((value) => { + uuid_value = value; + }); - const fetchOpts = { - method: 'GET', - headers: { - uuid: uuid_value, - }, - }; - const res = await fetch(url, fetchOpts) - unsubscribe(); - const resJs = await res.json() - return parseFormat(JSON.stringify(resJs)) + const fetchOpts = { + method: 'GET', + headers: { + uuid: uuid_value + } + }; + const res = await fetch(url, fetchOpts); + unsubscribe(); + const resJs = await res.json(); + return parseFormat(JSON.stringify(resJs)); } function parseFormat(jsonString: any): ApiResponse { - return JSON.parse(jsonString, (key, value) => { - if (typeof value === 'string') { - const dateRegex = /^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}.\d{3}Z$/; - if (dateRegex.test(value)) { - return new Date(value); - } - } - return value - }); -} \ No newline at end of file + return JSON.parse(jsonString, (key, value) => { + if (typeof value === 'string') { + const dateRegex = /^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}.\d{3}Z$/; + if (dateRegex.test(value)) { + return new Date(value); + } + } + return value; + }); +} diff --git a/src/lib/ldb/staff/staff-ldb.svelte b/src/lib/ldb/staff/staff-ldb.svelte index f914932..57fcd0d 100644 --- a/src/lib/ldb/staff/staff-ldb.svelte +++ b/src/lib/ldb/staff/staff-ldb.svelte @@ -29,7 +29,7 @@ title = data.data.locationName; return data.data; } - throw new Error("Unable to Fetch Data") + throw new Error('Unable to Fetch Data'); }