Skip to content
Snippets Groups Projects
Commit 0673e49a authored by Hugo SUBTIL's avatar Hugo SUBTIL
Browse files

feat: add health check

parent d918fb7e
No related branches found
No related tags found
No related merge requests found
import { Controller, Get } from '@nestjs/common'; import { Controller, Get } from '@nestjs/common';
import { AppService } from './app.service';
@Controller() @Controller()
export class AppController { export class AppController {
constructor(private readonly appService: AppService) {} private start: number;
@Get() constructor() {
getHello(): string { this.start = Date.now();
return this.appService.getHello(); }
@Get('healthcheck')
async healthcheck() {
const now = Date.now();
return {
status: 'API Online',
uptime: Number((now - this.start) / 1000).toFixed(0),
};
} }
} }
import { Module } from '@nestjs/common'; import { Module } from '@nestjs/common';
import { MongooseModule } from '@nestjs/mongoose'; import { MongooseModule } from '@nestjs/mongoose';
import { AppController } from './app.controller'; import { AppController } from './app.controller';
import { AppService } from './app.service';
import { StructuresModule } from './structures/structures.module'; import { StructuresModule } from './structures/structures.module';
import { ConfigurationModule } from './configuration/configuration.module'; import { ConfigurationModule } from './configuration/configuration.module';
import { CategoriesModule } from './categories/categories.module'; import { CategoriesModule } from './categories/categories.module';
@Module({ @Module({
imports: [ imports: [
ConfigurationModule, ConfigurationModule,
...@@ -16,6 +14,5 @@ import { CategoriesModule } from './categories/categories.module'; ...@@ -16,6 +14,5 @@ import { CategoriesModule } from './categories/categories.module';
CategoriesModule, CategoriesModule,
], ],
controllers: [AppController], controllers: [AppController],
providers: [AppService],
}) })
export class AppModule {} export class AppModule {}
import { Injectable } from '@nestjs/common';
@Injectable()
export class AppService {
getHello(): string {
return 'Hello World!';
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment