All files / app/pages version.json.ts

0% Statements 0/10
0% Branches 0/8
0% Functions 0/2
0% Lines 0/9

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24                                               
import type { GetServerSideProps } from "next";
 
const startTime = Date.now();
const STABLE_THRESHOLD_MS = 5 * 60 * 1000;
 
export const getServerSideProps: GetServerSideProps = async ({ res }) => {
  res.setHeader("Content-Type", "application/json");
  res.write(
    JSON.stringify({
      version: process.env.NEXT_PUBLIC_VERSION || "unknown",
      display_version: process.env.NEXT_PUBLIC_DISPLAY_VERSION || "dev",
      commit_sha: process.env.NEXT_PUBLIC_COMMIT_SHA || "unknown",
      pipeline_id: process.env.PIPELINE_ID || "unknown",
      stable: Date.now() - startTime >= STABLE_THRESHOLD_MS,
    }),
  );
  res.end();
  return { props: {} };
};
 
export default function Version() {
  return null;
}