import { Controller, Get } from "@nestjs/common";

@Controller()
export class AppController {
  @Get("health")
  health() {
    return { status: "ok" };
  }

  /**
   * What is actually running. The three values are baked into the image at
   * build time by .gitea/workflows/build.yml (see docker/api.Dockerfile) and
   * are the only way to confirm a deploy — or a rollback — landed: the tag you
   * dispatched and the code inside the container can disagree if a stack was
   * applied without pulling, or if the app stack still names an older tag.
   *
   * Deliberately unauthenticated, same as /health: the deploy workflow has to
   * read it with no session, and it exposes nothing an attacker could not
   * already infer from the repo.
   */
  @Get("version")
  version() {
    return {
      service: "api",
      version: process.env.APP_VERSION ?? "dev",
      gitSha: process.env.GIT_SHA ?? "unknown",
      buildDate: process.env.BUILD_DATE ?? "unknown",
    };
  }
}
