-
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
cd77b65
commit ae403a6
Showing
6 changed files
with
66 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,25 @@ | ||
<script> | ||
/** | ||
* @typedef {object} Props | ||
* @property {string} apiVersion | ||
*/ | ||
/** @type {Props} */ | ||
let { apiVersion } = $props(); | ||
const apiVersionWOSemicolon = $derived(apiVersion.replace(/\;$/, '')); | ||
</script> | ||
|
||
<footer class="h-[10lvh] w-full border-t-2 border-neutral-100 dark:border-neutral-700"> | ||
<div class="h-full flex place-content-center items-center"> | ||
<div class="h-full flex flex-col place-content-center items-center"> | ||
<a | ||
class="text-hearchco-primary dark:text-hearchco-secondary font-bold hover:underline" | ||
href="https://github.com/hearchco" | ||
> | ||
Source code | ||
</a> | ||
<p class="text-neutral-600 dark:text-neutral-300 font-light"> | ||
Agent version: {apiVersionWOSemicolon} | ||
</p> | ||
</div> | ||
</footer> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import { error } from '@sveltejs/kit'; | ||
import { createApiUrl } from '$lib/functions/api/createurl.js'; | ||
|
||
/** | ||
* @param {typeof fetch} [fetcher] | ||
* @returns {Promise<string>} | ||
*/ | ||
export async function fetchVersion(fetcher = fetch) { | ||
/** @type {URL} */ | ||
let apiUrl; | ||
try { | ||
apiUrl = createApiUrl('versionz'); | ||
} catch (/** @type {any} */ err) { | ||
// Internal Server Error | ||
throw error(500, `Failed to create API URL: ${err.message}`); | ||
} | ||
|
||
/** @type {Response} */ | ||
let response; | ||
try { | ||
response = await fetcher(apiUrl, { | ||
method: 'GET', // POST doesn't cache on CDN | ||
headers: { | ||
Accept: 'text/plain', | ||
'Accept-Encoding': 'gzip, deflate, br' | ||
} | ||
}); | ||
} catch (/** @type {any} */ err) { | ||
// Bad Gateway | ||
throw error(502, `Failed to fetch version: ${err.message}`); | ||
} | ||
|
||
/** @type {string} */ | ||
const version = await response.text(); | ||
|
||
return version; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import { fetchVersion } from '$lib/functions/api/fetchversion'; | ||
|
||
/** @type {import('./$types').LayoutLoad} */ | ||
export async function load({ fetch }) { | ||
const apiVersion = await fetchVersion(fetch); | ||
return { | ||
apiVersion: apiVersion | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters