add ad service

This commit is contained in:
sbriat 2023-05-04 12:33:31 +02:00
parent 4667185a91
commit 6b8ea07929
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 UserController {
constructor(
@Inject(WINSTON_MODULE_PROVIDER) private readonly logger: Logger,
) {}
@RabbitSubscribe({
name: 'loggingUserCreateInfo',
})
public async userCreatedInfoHandler(message: string) {
this.logger.configure(loggerOptions('user', level.info, 'info', 'create'));
this.logger.info(JSON.parse(message));
}
@RabbitSubscribe({
name: 'loggingUserCreateWarning',
})
public async userCreatedWarningHandler(message: string) {
this.logger.configure(
loggerOptions('user', level.warning, 'warning', 'create'),
);
this.logger.warning(JSON.parse(message));
}
@RabbitSubscribe({
name: 'loggingUserCreateCrit',
})
public async userCreatedCriticalHandler(message: string) {
this.logger.configure(
loggerOptions('user', level.crit, 'critical', 'create'),
);
this.logger.crit(JSON.parse(message));
}
@RabbitSubscribe({
name: 'loggingUserDeleteInfo',
})
public async userDeletedInfoHandler(message: string) {
this.logger.configure(loggerOptions('user', level.info, 'info', 'delete'));
this.logger.info(JSON.parse(message));
}
@RabbitSubscribe({
name: 'loggingUserDeleteCrit',
})
public async userDeletedCriticalHandler(message: string) {
this.logger.configure(
loggerOptions('user', level.crit, 'critical', 'delete'),
);
this.logger.crit(JSON.parse(message));
}
@RabbitSubscribe({
name: 'loggingUserReadWarning',
})
public async userReadWarningHandler(message: string) {
this.logger.configure(
loggerOptions('user', level.warning, 'warning', 'read'),
);
this.logger.warning(JSON.parse(message));
}
@RabbitSubscribe({
name: 'loggingUserUpdateInfo',
})
public async userUpdatedInfoHandler(message: string) {
this.logger.configure(loggerOptions('user', level.info, 'info', 'update'));
this.logger.info(JSON.parse(message));
}
@RabbitSubscribe({
name: 'loggingUserUpdateCrit',
})
public async userUpdatedCriticalHandler(message: string) {
this.logger.configure(
loggerOptions('user', level.crit, 'critical', 'update'),
);
this.logger.crit(JSON.parse(message));
}
@RabbitSubscribe({
name: 'loggingUserHealthCrit',
})
public async userHealthCriticalHandler(message: string) {
this.logger.configure(
loggerOptions('user', level.crit, 'critical', 'health'),
);
this.logger.crit(JSON.parse(message));
}
}