Merge branch 'adService' into 'main'

add ad service

See merge request v3/service/logger!18
This commit is contained in:
Sylvain Briat 2023-05-04 10:35:49 +00:00
commit 7ed387f087
2 changed files with 135 additions and 0 deletions

View File

@ -10,6 +10,7 @@ import { TerritoryController } from './logger/adapters/primaries/territory.contr
import { GatewayApiController } from './logger/adapters/primaries/gateway-api.controller';
import { AdminApiController } from './logger/adapters/primaries/admin-api.controller';
import { MatcherController } from './logger/adapters/primaries/matcher.controller';
import { AdController } from './logger/adapters/primaries/ad.controller';
@Module({
imports: [
@ -31,6 +32,42 @@ import { MatcherController } from './logger/adapters/primaries/matcher.controlle
exchange: configService.get<string>('RMQ_EXCHANGE'),
routingKey: 'logging.admin-api.health.crit',
},
loggingAdCreateInfo: {
exchange: configService.get<string>('RMQ_EXCHANGE'),
routingKey: 'logging.ad.create.info',
},
loggingAdCreateWarning: {
exchange: configService.get<string>('RMQ_EXCHANGE'),
routingKey: 'logging.ad.create.warning',
},
loggingAdCreateCrit: {
exchange: configService.get<string>('RMQ_EXCHANGE'),
routingKey: 'logging.ad.create.crit',
},
loggingAdDeleteInfo: {
exchange: configService.get<string>('RMQ_EXCHANGE'),
routingKey: 'logging.ad.delete.info',
},
loggingAdDeleteCrit: {
exchange: configService.get<string>('RMQ_EXCHANGE'),
routingKey: 'logging.ad.delete.crit',
},
loggingAdReadWarning: {
exchange: configService.get<string>('RMQ_EXCHANGE'),
routingKey: 'logging.ad.read.warning',
},
loggingAdUpdateInfo: {
exchange: configService.get<string>('RMQ_EXCHANGE'),
routingKey: 'logging.ad.update.info',
},
loggingAdUpdateCrit: {
exchange: configService.get<string>('RMQ_EXCHANGE'),
routingKey: 'logging.ad.update.crit',
},
loggingAdHealthCrit: {
exchange: configService.get<string>('RMQ_EXCHANGE'),
routingKey: 'logging.ad.health.crit',
},
loggingAuthCreateCrit: {
exchange: configService.get<string>('RMQ_EXCHANGE'),
routingKey: 'logging.auth.create.crit',
@ -184,6 +221,7 @@ import { MatcherController } from './logger/adapters/primaries/matcher.controlle
}),
],
controllers: [
AdController,
AuthController,
UserController,
ConfigurationController,

View File

@ -0,0 +1,97 @@
import { RabbitSubscribe } from '@golevelup/nestjs-rabbitmq';
import { Controller, Inject } from '@nestjs/common';
import { WINSTON_MODULE_PROVIDER } from 'nest-winston';
import { Logger } from 'winston';
import { level } from './logger/level.enum';
import loggerOptions from './logger/logger';
@Controller()
export class AdController {
constructor(
@Inject(WINSTON_MODULE_PROVIDER) private readonly logger: Logger,
) {}
@RabbitSubscribe({
name: 'loggingAdCreateInfo',
})
public async adCreatedInfoHandler(message: string) {
this.logger.configure(loggerOptions('ad', level.info, 'info', 'create'));
this.logger.info(JSON.parse(message));
}
@RabbitSubscribe({
name: 'loggingAdCreateWarning',
})
public async adCreatedWarningHandler(message: string) {
this.logger.configure(
loggerOptions('ad', level.warning, 'warning', 'create'),
);
this.logger.warning(JSON.parse(message));
}
@RabbitSubscribe({
name: 'loggingAdCreateCrit',
})
public async adCreatedCriticalHandler(message: string) {
this.logger.configure(
loggerOptions('ad', level.crit, 'critical', 'create'),
);
this.logger.crit(JSON.parse(message));
}
@RabbitSubscribe({
name: 'loggingAdDeleteInfo',
})
public async adDeletedInfoHandler(message: string) {
this.logger.configure(loggerOptions('ad', level.info, 'info', 'delete'));
this.logger.info(JSON.parse(message));
}
@RabbitSubscribe({
name: 'loggingAdDeleteCrit',
})
public async adDeletedCriticalHandler(message: string) {
this.logger.configure(
loggerOptions('ad', level.crit, 'critical', 'delete'),
);
this.logger.crit(JSON.parse(message));
}
@RabbitSubscribe({
name: 'loggingAdReadWarning',
})
public async adReadWarningHandler(message: string) {
this.logger.configure(
loggerOptions('ad', level.warning, 'warning', 'read'),
);
this.logger.warning(JSON.parse(message));
}
@RabbitSubscribe({
name: 'loggingAdUpdateInfo',
})
public async adUpdatedInfoHandler(message: string) {
this.logger.configure(loggerOptions('ad', level.info, 'info', 'update'));
this.logger.info(JSON.parse(message));
}
@RabbitSubscribe({
name: 'loggingAdUpdateCrit',
})
public async adUpdatedCriticalHandler(message: string) {
this.logger.configure(
loggerOptions('ad', level.crit, 'critical', 'update'),
);
this.logger.crit(JSON.parse(message));
}
@RabbitSubscribe({
name: 'loggingAdHealthCrit',
})
public async adHealthCriticalHandler(message: string) {
this.logger.configure(
loggerOptions('ad', level.crit, 'critical', 'health'),
);
this.logger.crit(JSON.parse(message));
}
}