84 lines
		
	
	
		
			2.4 KiB
		
	
	
	
		
			TypeScript
		
	
	
	
			
		
		
	
	
			84 lines
		
	
	
		
			2.4 KiB
		
	
	
	
		
			TypeScript
		
	
	
	
| import { RabbitSubscribe } from '@golevelup/nestjs-rabbitmq';
 | |
| import { Controller, Inject } from '@nestjs/common';
 | |
| import { WINSTON_MODULE_PROVIDER } from 'nest-winston';
 | |
| import { Logger } from 'winston';
 | |
| import loggerOptions from '../logger.options';
 | |
| import { level } from '../level.enum';
 | |
| 
 | |
| @Controller()
 | |
| export class AuthController {
 | |
|   constructor(
 | |
|     @Inject(WINSTON_MODULE_PROVIDER) private readonly logger: Logger,
 | |
|   ) {}
 | |
| 
 | |
|   @RabbitSubscribe({
 | |
|     name: 'loggingAuthCreatedCrit',
 | |
|   })
 | |
|   public async authCreatedCriticalHandler(message: string) {
 | |
|     this.logger.configure(
 | |
|       loggerOptions('auth', level.crit, 'critical', 'created'),
 | |
|     );
 | |
|     this.logger.crit(JSON.parse(message));
 | |
|   }
 | |
| 
 | |
|   @RabbitSubscribe({
 | |
|     name: 'loggingAuthDeletedCrit',
 | |
|   })
 | |
|   public async authDeletedCriticalHandler(message: string) {
 | |
|     this.logger.configure(
 | |
|       loggerOptions('auth', level.crit, 'critical', 'deleted'),
 | |
|     );
 | |
|     this.logger.crit(JSON.parse(message));
 | |
|   }
 | |
| 
 | |
|   @RabbitSubscribe({
 | |
|     name: 'loggingAuthUsernameAddedWarning',
 | |
|   })
 | |
|   public async authUsernameAddedWarningHandler(message: string) {
 | |
|     this.logger.configure(
 | |
|       loggerOptions('auth', level.warning, 'warning', 'username-added'),
 | |
|     );
 | |
|     this.logger.warning(JSON.parse(message));
 | |
|   }
 | |
| 
 | |
|   @RabbitSubscribe({
 | |
|     name: 'loggingAuthUsernameDeletedWarning',
 | |
|   })
 | |
|   public async authUsernameDeletedWarningHandler(message: string) {
 | |
|     this.logger.configure(
 | |
|       loggerOptions('auth', level.warning, 'warning', 'username-deleted'),
 | |
|     );
 | |
|     this.logger.warning(JSON.parse(message));
 | |
|   }
 | |
| 
 | |
|   @RabbitSubscribe({
 | |
|     name: 'loggingAuthPasswordUpdatedWarning',
 | |
|   })
 | |
|   public async authPasswordUpdatedWarningHandler(message: string) {
 | |
|     this.logger.configure(
 | |
|       loggerOptions('auth', level.warning, 'warning', 'password-updated'),
 | |
|     );
 | |
|     this.logger.warning(JSON.parse(message));
 | |
|   }
 | |
| 
 | |
|   @RabbitSubscribe({
 | |
|     name: 'loggingAuthUsernameUpdatedWarning',
 | |
|   })
 | |
|   public async authUsernameUpdatedWarningHandler(message: string) {
 | |
|     this.logger.configure(
 | |
|       loggerOptions('auth', level.warning, 'warning', 'username-updated'),
 | |
|     );
 | |
|     this.logger.warning(JSON.parse(message));
 | |
|   }
 | |
| 
 | |
|   @RabbitSubscribe({
 | |
|     name: 'loggingAuthHealthCrit',
 | |
|   })
 | |
|   public async authHealthCriticalHandler(message: string) {
 | |
|     this.logger.configure(
 | |
|       loggerOptions('auth', level.crit, 'critical', 'health'),
 | |
|     );
 | |
|     this.logger.crit(JSON.parse(message));
 | |
|   }
 | |
| }
 |