diff --git a/frontend/src/lib/components/ui/badge/badge.svelte b/frontend/src/lib/components/ui/badge/badge.svelte new file mode 100644 index 0000000..0acc5eb --- /dev/null +++ b/frontend/src/lib/components/ui/badge/badge.svelte @@ -0,0 +1,49 @@ + + + + + + {@render children?.()} + diff --git a/frontend/src/lib/components/ui/badge/index.ts b/frontend/src/lib/components/ui/badge/index.ts new file mode 100644 index 0000000..f05fb87 --- /dev/null +++ b/frontend/src/lib/components/ui/badge/index.ts @@ -0,0 +1,2 @@ +export { default as Badge } from './badge.svelte'; +export { badgeVariants, type BadgeVariant } from './badge.svelte'; diff --git a/frontend/src/lib/config/config.ts b/frontend/src/lib/config/config.ts index 56145a1..b0e1788 100644 --- a/frontend/src/lib/config/config.ts +++ b/frontend/src/lib/config/config.ts @@ -1,3 +1,4 @@ export const cfg = { - apiBaseUrl: import.meta.env.VITE_API_BASE_URL || 'http://localhost:3003/api/users' + apiBaseUrl: import.meta.env.VITE_API_BASE_URL || 'http://localhost:3003/api/users', + apiHealthCheckUrl: import.meta.env.VITE_API_HEALTH_CHECK_URL || 'http://localhost:3003/api/ping' }; diff --git a/frontend/src/lib/service/authApiService.ts b/frontend/src/lib/service/authApiService.ts index 0f9e057..ea46a5c 100644 --- a/frontend/src/lib/service/authApiService.ts +++ b/frontend/src/lib/service/authApiService.ts @@ -37,6 +37,15 @@ import { cfg } from '$lib/config/config.js'; type MethodType = 'GET' | 'POST' | 'PUT' | 'DELETE' | 'PATCH'; +export const healthCheck = async (): Promise => { + try { + const response = await fetch(cfg.apiHealthCheckUrl, { method: 'GET' }); + return response.ok; + } catch { + return false; + } +}; + const apiFetcher = async ( path: string, method: MethodType, diff --git a/frontend/src/routes/+page.svelte b/frontend/src/routes/+page.svelte index 45944d3..82bc859 100644 --- a/frontend/src/routes/+page.svelte +++ b/frontend/src/routes/+page.svelte @@ -1,13 +1,20 @@
-

- Welcome to the Authentication Demo -

+
+

+ Welcome to the Authentication Demo +

+

+ This is a demo environment. Data is reset periodically. +

+ +
{#if browser} diff --git a/frontend/src/routes/HealthCheck.svelte b/frontend/src/routes/HealthCheck.svelte new file mode 100644 index 0000000..764c5a4 --- /dev/null +++ b/frontend/src/routes/HealthCheck.svelte @@ -0,0 +1,19 @@ + + +
+ {#if backendHealthCheck} + Backend is ready + {:else} + Backend is waking up... + {/if} +