import type { APIRoute } from 'astro';

export const prerender = false;

const VERSION = {
  sha: import.meta.env.PUBLIC_BUILD_SHA || process.env.PUBLIC_BUILD_SHA || 'dev',
  builtAt: import.meta.env.PUBLIC_BUILD_TIME || process.env.PUBLIC_BUILD_TIME || new Date().toISOString(),
  ref: import.meta.env.PUBLIC_BUILD_REF || process.env.PUBLIC_BUILD_REF || 'local',
};

export const GET: APIRoute = () =>
  new Response(JSON.stringify(VERSION), {
    headers: {
      'Content-Type': 'application/json',
      'Cache-Control': 'no-store, must-revalidate',
    },
  });
