Commit e2d304f7 authored by Fabien Forestier's avatar Fabien Forestier
Browse files

Merge branch 'development' into 'master'

Version 1.2.0

See merge request refonte-data/service-email!1
parents 82c49b9a b90837fe
Pipeline #2452 passed with stage
in 6 seconds
......@@ -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.
{
"name": "service-email",
"version": "1.1.2",
"version": "1.2.0",
"description": "description",
"author": "",
"license": "MIT",
......@@ -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",
......@@ -30,6 +32,8 @@
"moment-timezone": "^0.5.23",
"reflect-metadata": "^0.1.12",
"rxjs": "^6.2.2",
"serve-favicon": "^2.5.0",
"swagger-stats": "^0.95.7",
"typescript": "^3.0.1",
"useragent": "^2.3.0"
},
......
......@@ -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
......@@ -2,11 +2,18 @@ import { NestFactory } from '@nestjs/core';
import { AppModule } from './app.module';
import { SwaggerModule, DocumentBuilder } from '@nestjs/swagger';
import { ValidationPipe } from '@nestjs/common';
import * as fs from 'fs';
import * as swStats from 'swagger-stats';
import * as favicon from 'serve-favicon';
import * as path from 'path';
async function bootstrap() {
const app = await NestFactory.create(AppModule);
app.enableCors({ credentials: true, origin: true});
app.enableCors({ credentials: true, origin: true });
app.use(favicon(path.join(__dirname, '../favicon.ico')));
const options = new DocumentBuilder()
.setBasePath('')
.setTitle('Email service API')
......@@ -15,9 +22,12 @@ async function bootstrap() {
.addTag('email')
.build();
const document = SwaggerModule.createDocument(app, options);
fs.writeFileSync('./swagger-spec.json', JSON.stringify(document));
// Enable stats middleware based on the generated swagger document
app.use(swStats.getMiddleware(document));
SwaggerModule.setup('api-doc', app, document);
app.useGlobalPipes(new ValidationPipe());
await app.listen(3000);
......
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