From 55188d2e5d91fcd514bd99952fc836bd39778e7e Mon Sep 17 00:00:00 2001 From: Xin Feng <126309503+danielxfeng@users.noreply.github.com> Date: Sun, 11 Jan 2026 12:51:34 +0200 Subject: [PATCH 1/3] feat/frontend: add healthy check --- .../src/lib/components/ui/badge/badge.svelte | 49 +++++++++++++++++++ frontend/src/lib/components/ui/badge/index.ts | 2 + frontend/src/lib/config/config.ts | 3 +- frontend/src/lib/service/authApiService.ts | 9 ++++ frontend/src/routes/+page.svelte | 10 ++-- frontend/src/routes/HealthCheck.svelte | 19 +++++++ 6 files changed, 88 insertions(+), 4 deletions(-) create mode 100644 frontend/src/lib/components/ui/badge/badge.svelte create mode 100644 frontend/src/lib/components/ui/badge/index.ts create mode 100644 frontend/src/routes/HealthCheck.svelte 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..eb68d2c 100644 --- a/frontend/src/routes/+page.svelte +++ b/frontend/src/routes/+page.svelte @@ -1,13 +1,17 @@
-

- Welcome to the Authentication Demo -

+
+

+ Welcome to the Authentication Demo +

+ +
{#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} +
From 66ddee164836949d02de2fb00106341d79e5e75d Mon Sep 17 00:00:00 2001 From: Xin Feng <126309503+danielxfeng@users.noreply.github.com> Date: Sun, 11 Jan 2026 12:57:28 +0200 Subject: [PATCH 2/3] feat/frontend: add demo environment notice to the welcome page --- frontend/src/routes/+page.svelte | 1 + 1 file changed, 1 insertion(+) diff --git a/frontend/src/routes/+page.svelte b/frontend/src/routes/+page.svelte index eb68d2c..5792a49 100644 --- a/frontend/src/routes/+page.svelte +++ b/frontend/src/routes/+page.svelte @@ -10,6 +10,7 @@

Welcome to the Authentication Demo

+

This is a demo environment. Data is reset periodically.

From b981a04bca63cfa6086ace90097093bd715d9f81 Mon Sep 17 00:00:00 2001 From: Xin Feng <126309503+danielxfeng@users.noreply.github.com> Date: Sun, 11 Jan 2026 12:57:51 +0200 Subject: [PATCH 3/3] chore/frontend: prettier --- frontend/src/routes/+page.svelte | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/frontend/src/routes/+page.svelte b/frontend/src/routes/+page.svelte index 5792a49..82bc859 100644 --- a/frontend/src/routes/+page.svelte +++ b/frontend/src/routes/+page.svelte @@ -10,7 +10,9 @@

Welcome to the Authentication Demo

-

This is a demo environment. Data is reset periodically.

+

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