import { Controller , Get } from '@nestjs/common' ; import { ApiTags } from '@nestjs/swagger' ; import { SystemService } from './systems.service' ; import { UserService } from '../user/user.service' ; import { ModelService } from '../model/model.service' ; import { HealthCheckService , DNSHealthIndicator , HealthCheck , MongooseHealthIndicator } from '@nestjs/terminus' ; import config from '../config' ; @ ApiTags ( 'Model' ) @ Controller ( 'System' ) export class SystemController { constructor ( private readonly userService , private readonly modelService , private readonly systemService , private readonly health , private readonly mongo ) { } @ Get ( 'stats' ) async fetchStats ( ) { return { 'user_count' : await this . userService . count ( ) , 'model_count' : await this . modelService . count ( ) } ; } @ Get ( 'health' ) @ HealthCheck ( ) check ( ) { return this . health . check ( [ ( ) => this . mongo . pingCheck ( 'aid-database' , { connection : config . MONGO_URI } ) ] ) ; } }