feat(health): expose app version in /health response

Reads application version from package.json via env.ts readPackageVersion()
and returns it alongside status so deploy verification is instant:
curl https://upload.asepharyana.my.id/health -> {status: ok, version: X.Y.Z}
This commit is contained in:
asepharyana
2026-09-06 00:42:39 +07:00
parent bdda2d9884
commit 0782d0f993
2 changed files with 38 additions and 1 deletions
@@ -1,4 +1,5 @@
import { sql } from 'drizzle-orm';
import { config } from '../../../env';
import { db } from '../../../infrastructure/persistence/drizzle/index';
import logger from '../../../shared/logger/index';
import { getErrorMessage } from '../../../shared/utils/file';
@@ -16,7 +17,7 @@ import { getErrorMessage } from '../../../shared/utils/file';
export const handleHealth = async (_req: Request): Promise<Response> => {
try {
await db.execute(sql`SELECT 1`);
return Response.json({ status: 'ok' }, { status: 200 });
return Response.json({ status: 'ok', version: config.appVersion }, { status: 200 });
} catch (error: unknown) {
const message = getErrorMessage(error);
logger.error('Health check failed', { error: message });