Commit 1b911606 authored by FORESTIER Fabien's avatar FORESTIER Fabien
Browse files

Add health module

parent 82c49b9a
......@@ -23,8 +23,8 @@ build_release:
stage: build
only:
- tags
except:
- /^(?!master).+@/
# except:
# - /^(?!master).+@/
script:
- export TAG=$(echo $CI_COMMIT_TAG | sed 's/v//g')
- export MAIL_SERVICE_BIND_PORT=3000
......
This diff is collapsed.
......@@ -20,9 +20,11 @@
"webpack": "webpack --config webpack.config.js"
},
"dependencies": {
"@godaddy/terminus": "^4.1.0",
"@nestjs/common": "^5.1.0",
"@nestjs/core": "^5.1.0",
"@nestjs/swagger": "^2.5.1",
"@nestjs/terminus": "^5.5.0",
"amqplib": "^0.5.2",
"class-transformer": "^0.1.9",
"class-validator": "^0.9.1",
......@@ -68,4 +70,4 @@
"coverageDirectory": "../coverage",
"testEnvironment": "node"
}
}
\ No newline at end of file
}
......@@ -3,9 +3,14 @@ import { EmailModule } from './email/email.module';
import { ConfigModule } from './configuration/config.module';
import { APP_GUARD } from '@nestjs/core';
import { GroupsGuard } from './guards/groups.guards';
import { HealthModule } from './health/health.module';
@Module({
imports: [ConfigModule, EmailModule],
imports: [
ConfigModule,
HealthModule,
EmailModule,
],
controllers: [],
providers: [
{
......@@ -14,4 +19,4 @@ import { GroupsGuard } from './guards/groups.guards';
},
],
})
export class AppModule {}
export class AppModule { }
import {
TerminusEndpoint,
TerminusOptionsFactory,
TerminusModuleOptions,
MicroserviceHealthIndicator,
} from '@nestjs/terminus';
import { Injectable } from '@nestjs/common';
import { Transport } from '@nestjs/microservices';
import { ConfigService } from '../configuration/config.service';
@Injectable()
export class HealthCheckService implements TerminusOptionsFactory {
constructor(
private configService: ConfigService,
private readonly _microserviceHealthIndicator: MicroserviceHealthIndicator,
) { }
createTerminusOptions(): TerminusModuleOptions {
const config = this.configService.config;
const healthEndpoint: TerminusEndpoint = {
url: '/health',
healthIndicators: [
async () => this._microserviceHealthIndicator.pingCheck('rabbitMQ', {
transport: Transport.RMQ,
options: {
urls: [
`amqp://${config.rabbitMQ.user}:${config.rabbitMQ.password}@${config.rabbitMQ.host}:${config.rabbitMQ.port}`,
],
queue: config.mailerQueue,
},
}),
],
};
return {
endpoints: [healthEndpoint],
};
}
}
\ No newline at end of file
import { Module } from '@nestjs/common';
import { TerminusModule } from '@nestjs/terminus';
import { HealthCheckService } from './health-check.service';
@Module({
imports: [
TerminusModule.forRootAsync({
useClass: HealthCheckService,
}),
],
})
export class HealthModule { }
\ No newline at end of file
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment