feat(build): inject build time and version into health endpoint
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 <noreply@anthropic.com>
This commit is contained in:
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "osit-aether-app-svelte",
|
"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",
|
"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/",
|
"homepage": "https://oneskyit.com/",
|
||||||
"private": true,
|
"private": true,
|
||||||
|
|||||||
3
src/app.d.ts
vendored
3
src/app.d.ts
vendored
@@ -10,6 +10,9 @@ declare namespace App {
|
|||||||
// interface Platform {}
|
// interface Platform {}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
declare const __BUILD_TIME__: string;
|
||||||
|
declare const __BUILD_VERSION__: string;
|
||||||
|
|
||||||
declare global {
|
declare global {
|
||||||
namespace App {
|
namespace App {
|
||||||
interface Platform {}
|
interface Platform {}
|
||||||
|
|||||||
@@ -1,16 +1,13 @@
|
|||||||
import { json } from '@sveltejs/kit';
|
import { json } from '@sveltejs/kit';
|
||||||
import type { RequestHandler } from './$types';
|
import type { RequestHandler } from './$types';
|
||||||
|
|
||||||
/**
|
|
||||||
* Health Check Endpoint
|
|
||||||
* Used by Docker and Nginx to verify the service is running.
|
|
||||||
*/
|
|
||||||
export const GET: RequestHandler = async () => {
|
export const GET: RequestHandler = async () => {
|
||||||
return json(
|
return json(
|
||||||
{
|
{
|
||||||
status: 'healthy',
|
status: 'healthy',
|
||||||
timestamp: new Date().toISOString(),
|
|
||||||
service: 'aether-app-sveltekit',
|
service: 'aether-app-sveltekit',
|
||||||
|
version: __BUILD_VERSION__,
|
||||||
|
build_time: __BUILD_TIME__,
|
||||||
node_env: process.env.NODE_ENV || 'development'
|
node_env: process.env.NODE_ENV || 'development'
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,9 +1,16 @@
|
|||||||
import { defineConfig } from 'vite';
|
import { defineConfig } from 'vite';
|
||||||
import { sveltekit } from '@sveltejs/kit/vite';
|
import { sveltekit } from '@sveltejs/kit/vite';
|
||||||
import tailwindcss from '@tailwindcss/vite';
|
import tailwindcss from '@tailwindcss/vite';
|
||||||
|
import { readFileSync } from 'fs';
|
||||||
|
|
||||||
|
const pkg = JSON.parse(readFileSync('./package.json', 'utf-8'));
|
||||||
|
|
||||||
export default defineConfig({
|
export default defineConfig({
|
||||||
cacheDir: 'node_modules/.vite',
|
cacheDir: 'node_modules/.vite',
|
||||||
|
define: {
|
||||||
|
__BUILD_TIME__: JSON.stringify(new Date().toISOString()),
|
||||||
|
__BUILD_VERSION__: JSON.stringify(pkg.version)
|
||||||
|
},
|
||||||
plugins: [
|
plugins: [
|
||||||
tailwindcss(),
|
tailwindcss(),
|
||||||
sveltekit() // <-- Must come after Tailwind
|
sveltekit() // <-- Must come after Tailwind
|
||||||
|
|||||||
Reference in New Issue
Block a user