Skip to content
Snippets Groups Projects
app.controller.ts 463 B
Newer Older
Hugo SUBTIL's avatar
Hugo SUBTIL committed
import { Controller, Get } from '@nestjs/common';
import { version } from '../package.json';
Hugo SUBTIL's avatar
Hugo SUBTIL committed
@Controller()
export class AppController {
Hugo SUBTIL's avatar
Hugo SUBTIL committed
  private start: number;
  private version: string = version;
Hugo SUBTIL's avatar
Hugo SUBTIL committed

Hugo SUBTIL's avatar
Hugo SUBTIL committed
  constructor() {
    this.start = Date.now();
  }

  @Get('healthcheck')
  async healthcheck() {
    const now = Date.now();
    return {
      status: 'API Online',
      uptime: Number((now - this.start) / 1000).toFixed(0),
Hugo SUBTIL's avatar
Hugo SUBTIL committed
    };
Hugo SUBTIL's avatar
Hugo SUBTIL committed
  }
}