import { Controller, Get, Inject } from '@nestjs/common';
import { APP_ENVIRONMENT } from '../../../../libs/configuration/src';
import type { AppEnvironment } from '../../../../libs/configuration/src';

interface SafeVersionInfo {
  appVersion: string;
  teamCityBuildNumber: string;
  sourceRevision: string;
}

@Controller('version')
export class VersionController {
  constructor(
    @Inject(APP_ENVIRONMENT) private readonly environment: AppEnvironment,
  ) {}

  @Get()
  version(): SafeVersionInfo {
    return {
      appVersion: this.environment.appVersion,
      teamCityBuildNumber: this.environment.teamCityBuildNumber,
      sourceRevision: this.environment.sourceRevision,
    };
  }
}
