From 467706b564cb7cdc0a1c48fa4658936fbfb28dbd Mon Sep 17 00:00:00 2001 From: Alexander Weber Date: Tue, 14 Nov 2023 13:48:52 +0100 Subject: [PATCH] linter fix --- src/console/console.module.ts | 2 +- src/core/logging/class-logger.ts | 7 ++-- src/core/logging/module-logger.spec.ts | 2 +- src/core/logging/nest-logger.spec.ts | 12 +++---- src/modules/health/health.module.ts | 5 ++- src/shared/config/json.config.ts | 1 - src/shared/config/logging.config.ts | 50 +++++++++++++------------- 7 files changed, 41 insertions(+), 38 deletions(-) diff --git a/src/console/console.module.ts b/src/console/console.module.ts index 293c613c7..6ebc5eb65 100644 --- a/src/console/console.module.ts +++ b/src/console/console.module.ts @@ -9,7 +9,7 @@ import { DbConfig, loadConfigFiles, loadEnvConfig, ServerConfig } from '../share import { mappingErrorHandler } from '../shared/error/index.js'; import { DbConsole } from './db.console.js'; import { DbInitConsole } from './db-init.console.js'; -import { LoggerModule } from '../core/logging/logger.module'; +import { LoggerModule } from '../core/logging/logger.module.js'; @Module({ imports: [ diff --git a/src/core/logging/class-logger.ts b/src/core/logging/class-logger.ts index 7217ea54a..bf2a1e813 100644 --- a/src/core/logging/class-logger.ts +++ b/src/core/logging/class-logger.ts @@ -8,9 +8,12 @@ import { INQUIRER } from '@nestjs/core'; export class ClassLogger extends Logger { private logger: LoggerWinston; - private context: string | undefined; + private readonly context: string | undefined; - public constructor(moduleLogger: ModuleLogger, @Inject(INQUIRER) private parentClass: object) { + public constructor( + moduleLogger: ModuleLogger, + @Inject(INQUIRER) private parentClass: object, + ) { super(); this.logger = moduleLogger.getLogger(); this.context = `${moduleLogger.moduleName}.${this.parentClass?.constructor?.name}`; diff --git a/src/core/logging/module-logger.spec.ts b/src/core/logging/module-logger.spec.ts index 58727e8c1..7d40d1d05 100644 --- a/src/core/logging/module-logger.spec.ts +++ b/src/core/logging/module-logger.spec.ts @@ -11,7 +11,7 @@ describe('Module Logger', () => { it('should produce a sensible log message', () => { tfi.level = 'error'; tfi.message = 'Something bad happened'; - const formattedMessage = localFormatter(tfi); + const formattedMessage: string = localFormatter(tfi); expect(formattedMessage).toContain('Something bad happened'); expect(formattedMessage).toContain('error'); diff --git a/src/core/logging/nest-logger.spec.ts b/src/core/logging/nest-logger.spec.ts index 5e85165ab..39a045ec8 100644 --- a/src/core/logging/nest-logger.spec.ts +++ b/src/core/logging/nest-logger.spec.ts @@ -17,15 +17,15 @@ describe('The nest Logger', () => { it('should produce correct log messages', () => { const nestLogger = module.get(NestLogger); - nestLogger.log('Blah'); - nestLogger.debug?.('Blah'); - nestLogger.error('Blah'); - nestLogger.warn('Blah'); - nestLogger.verbose?.('Blah'); + nestLogger.log('Test'); + nestLogger.debug?.('Test'); + nestLogger.error('Test'); + nestLogger.warn('Test'); + nestLogger.verbose?.('Test'); expect(moduleLogger.getLogger).toHaveBeenCalledTimes(5); expect(moduleLogger.getLogger().log.mock.calls - .every(v => v[1] as string == 'Blah')) + .every(v => v[1] as string == 'Test')) }); afterAll(async () => { diff --git a/src/modules/health/health.module.ts b/src/modules/health/health.module.ts index 8eb683601..517764f7d 100644 --- a/src/modules/health/health.module.ts +++ b/src/modules/health/health.module.ts @@ -4,5 +4,8 @@ import { HealthController } from './health.controller.js'; import { HttpModule } from '@nestjs/axios'; import { LoggerModule } from '../../core/logging/logger.module.js'; -@Module({ imports: [TerminusModule, HttpModule, LoggerModule.register(HealthModule.name)], controllers: [HealthController] }) +@Module({ + imports: [TerminusModule, HttpModule, LoggerModule.register(HealthModule.name)], + controllers: [HealthController], +}) export class HealthModule {} diff --git a/src/shared/config/json.config.ts b/src/shared/config/json.config.ts index fc20efe7e..d46f603c0 100644 --- a/src/shared/config/json.config.ts +++ b/src/shared/config/json.config.ts @@ -7,7 +7,6 @@ import { KeycloakConfig } from './keycloak.config.js'; import { LoggingConfig } from './logging.config.js'; import { RedisConfig } from './redis.config.js'; - export class JsonConfig { @ValidateNested() @Type(() => HostConfig) diff --git a/src/shared/config/logging.config.ts b/src/shared/config/logging.config.ts index fc5b68e66..31c537262 100644 --- a/src/shared/config/logging.config.ts +++ b/src/shared/config/logging.config.ts @@ -1,39 +1,37 @@ import { IsNotEmpty, IsString } from 'class-validator'; export class LoggingConfig { + @IsString() + @IsNotEmpty() + public readonly DEFAULT_LOG_LEVEL!: string; - @IsString() - @IsNotEmpty() - public readonly DEFAULT_LOG_LEVEL!: string; + //Domain Modules - //Domain Modules + @IsString() + @IsNotEmpty() + public readonly PERSONMODULE_LOG_LEVEL!: string; - @IsString() - @IsNotEmpty() - public readonly PERSONMODULE_LOG_LEVEL!: string; + @IsString() + @IsNotEmpty() + public readonly ORGANISATIONMODULE_LOG_LEVEL!: string; - @IsString() - @IsNotEmpty() - public readonly ORGANISATIONMODULE_LOG_LEVEL!: string; + @IsString() + @IsNotEmpty() + public readonly ROLLEMODULE_LOG_LEVEL!: string; - @IsString() - @IsNotEmpty() - public readonly ROLLEMODULE_LOG_LEVEL!: string; + //Technical Modules - //Technical Modules + @IsString() + @IsNotEmpty() + public readonly KEYCLOAKMODULE_LOG_LEVEL!: string; - @IsString() - @IsNotEmpty() - public readonly KEYCLOAKMODULE_LOG_LEVEL!: string; + //SPSH Modules - //SPSH Modules - - @IsString() - @IsNotEmpty() - public readonly BACKENDFORFRONTENDMODULE_LOG_LEVEL!: string; - - @IsString() - @IsNotEmpty() - public readonly UIBACKENDMODULE_LOG_LEVEL!: string; + @IsString() + @IsNotEmpty() + public readonly BACKENDFORFRONTENDMODULE_LOG_LEVEL!: string; + @IsString() + @IsNotEmpty() + public readonly UIBACKENDMODULE_LOG_LEVEL!: string; }