-
-
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.
Merge pull request #318 from hearchco/as/feat/version
feat: versions
- Loading branch information
Showing
9 changed files
with
73 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,24 @@ | ||
<script> | ||
/** | ||
* @typedef {object} Props | ||
* @property {string} uiVersion | ||
* @property {string} apiVersion | ||
*/ | ||
/** @type {Props} */ | ||
let { uiVersion, apiVersion } = $props(); | ||
</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-sm text-neutral-600 dark:text-neutral-300 font-light"> | ||
UI ver: {uiVersion} | Agent ver: {apiVersion.replace(/;$/, '')} | ||
</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,11 @@ | ||
import { PUBLIC_UI_VERSION } from '$env/static/public'; | ||
import { fetchVersion } from '$lib/functions/api/fetchversion'; | ||
|
||
/** @type {import('./$types').LayoutLoad} */ | ||
export async function load({ fetch }) { | ||
const apiVersion = await fetchVersion(fetch); | ||
return { | ||
uiVersion: PUBLIC_UI_VERSION ?? 'dev', | ||
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