From 677ec9d918b98b53caba33b1979657fdbbe15bbc Mon Sep 17 00:00:00 2001 From: Scott Idem Date: Mon, 22 Jun 2026 15:13:04 -0400 Subject: [PATCH] feat(build): inject build time and version into health endpoint MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Vite define injects __BUILD_TIME__ and __BUILD_VERSION__ at build time so /health returns the exact timestamp and package version of the running build — useful for verifying deploys without guessing what changed. Co-Authored-By: Claude Sonnet 4.6 --- package.json | 2 +- src/app.d.ts | 3 +++ src/routes/health/+server.ts | 7 ++----- vite.config.ts | 7 +++++++ 4 files changed, 13 insertions(+), 6 deletions(-) diff --git a/package.json b/package.json index 9a6a7097..df78f48b 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "osit-aether-app-svelte", - "version": "3.00.65", + "version": "3.00.66", "description": "One Sky IT's Aether App created with Svelte, SvelteKit, Tailwind CSS, Lucide, Font Awesome, and Skeleton UI. -Scott Idem", "homepage": "https://oneskyit.com/", "private": true, diff --git a/src/app.d.ts b/src/app.d.ts index 9b354164..b8d467b1 100644 --- a/src/app.d.ts +++ b/src/app.d.ts @@ -10,6 +10,9 @@ declare namespace App { // interface Platform {} } +declare const __BUILD_TIME__: string; +declare const __BUILD_VERSION__: string; + declare global { namespace App { interface Platform {} diff --git a/src/routes/health/+server.ts b/src/routes/health/+server.ts index d98cf10d..451ce626 100644 --- a/src/routes/health/+server.ts +++ b/src/routes/health/+server.ts @@ -1,16 +1,13 @@ import { json } from '@sveltejs/kit'; import type { RequestHandler } from './$types'; -/** - * Health Check Endpoint - * Used by Docker and Nginx to verify the service is running. - */ export const GET: RequestHandler = async () => { return json( { status: 'healthy', - timestamp: new Date().toISOString(), service: 'aether-app-sveltekit', + version: __BUILD_VERSION__, + build_time: __BUILD_TIME__, node_env: process.env.NODE_ENV || 'development' }, { diff --git a/vite.config.ts b/vite.config.ts index 8034b963..52d8c4af 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -1,9 +1,16 @@ import { defineConfig } from 'vite'; import { sveltekit } from '@sveltejs/kit/vite'; import tailwindcss from '@tailwindcss/vite'; +import { readFileSync } from 'fs'; + +const pkg = JSON.parse(readFileSync('./package.json', 'utf-8')); export default defineConfig({ cacheDir: 'node_modules/.vite', + define: { + __BUILD_TIME__: JSON.stringify(new Date().toISOString()), + __BUILD_VERSION__: JSON.stringify(pkg.version) + }, plugins: [ tailwindcss(), sveltekit() // <-- Must come after Tailwind