Skip to content

Commit

Permalink
CR
Browse files Browse the repository at this point in the history
  • Loading branch information
samuel committed Jun 27, 2024
1 parent 70c0199 commit 8a4acca
Show file tree
Hide file tree
Showing 10 changed files with 22 additions and 43 deletions.
14 changes: 1 addition & 13 deletions apps/armory/src/main.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { ConfigService } from '@narval/config-module'
import { LoggerService, withCors, withSwagger } from '@narval/nestjs-shared'
import { withCors, withCustomLogger, withSwagger } from '@narval/nestjs-shared'
import { ClassSerializerInterceptor, INestApplication, Logger, ValidationPipe } from '@nestjs/common'
import { NestFactory, Reflector } from '@nestjs/core'
import { lastValueFrom, map, of, switchMap } from 'rxjs'
Expand All @@ -10,18 +10,6 @@ import { ApplicationExceptionFilter } from './shared/filter/application-exceptio
import { HttpExceptionFilter } from './shared/filter/http-exception.filter'
import { ZodExceptionFilter } from './shared/filter/zod-exception.filter'

/**
* Adds Narval custom logger.
*
* @param app - The INestApplication instance.
* @returns The modified INestApplication instance.
*/
const withCustomLogger = (app: INestApplication): INestApplication => {
app.useLogger(app.get(LoggerService))

return app
}

/**
* Adds global pipes to the application.
*
Expand Down
14 changes: 1 addition & 13 deletions apps/policy-engine/src/main.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { ConfigService } from '@narval/config-module'
import { LoggerService, withCors, withSwagger } from '@narval/nestjs-shared'
import { withCors, withCustomLogger, withSwagger } from '@narval/nestjs-shared'
import { INestApplication, Logger, ValidationPipe } from '@nestjs/common'
import { NestFactory } from '@nestjs/core'
import { lastValueFrom, map, of, switchMap } from 'rxjs'
Expand All @@ -9,18 +9,6 @@ import { PolicyEngineModule, ProvisionModule } from './policy-engine.module'
import { ApplicationExceptionFilter } from './shared/filter/application-exception.filter'
import { HttpExceptionFilter } from './shared/filter/http-exception.filter'

/**
* Adds Narval custom logger.
*
* @param app - The INestApplication instance.
* @returns The modified INestApplication instance.
*/
const withCustomLogger = (app: INestApplication): INestApplication => {
app.useLogger(app.get(LoggerService))

return app
}

/**
* Adds global pipes to the application.
*
Expand Down
14 changes: 1 addition & 13 deletions apps/vault/src/main.ts
Original file line number Diff line number Diff line change
@@ -1,24 +1,12 @@
import { ConfigService } from '@narval/config-module'
import { LoggerService, withCors, withSwagger } from '@narval/nestjs-shared'
import { withCors, withCustomLogger, withSwagger } from '@narval/nestjs-shared'
import { INestApplication, Logger, ValidationPipe } from '@nestjs/common'
import { NestFactory } from '@nestjs/core'
import { lastValueFrom, map, of, switchMap } from 'rxjs'
import { Config } from './main.config'
import { ADMIN_API_KEY_SECURITY, GNAP_SECURITY } from './main.constant'
import { MainModule, ProvisionModule } from './main.module'

/**
* Adds Narval custom logger.
*
* @param app - The INestApplication instance.
* @returns The modified INestApplication instance.
*/
const withCustomLogger = (app: INestApplication): INestApplication => {
app.useLogger(app.get(LoggerService))

return app
}

/**
* Adds global pipes to the application.
*
Expand Down
5 changes: 3 additions & 2 deletions packages/nestjs-shared/src/lib/module/index.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
export * from './http.module'
export * from './logger.module'
export * from './http/http.module'
export * from './logger/logger.module'
export * from './logger/service/logger.service'
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Module } from '@nestjs/common'
import { LoggerService } from '../service/logger.service'
import { LoggerService } from './service/logger.service'

@Module({
providers: [LoggerService],
Expand Down
1 change: 0 additions & 1 deletion packages/nestjs-shared/src/lib/service/index.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
export * from './logger.service'
export * from './null-logger.service'
1 change: 1 addition & 0 deletions packages/nestjs-shared/src/lib/util/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
export * as coerce from './coerce.util'
export * as secret from './secret.util'
export * from './with-cors.util'
export * from './with-custom-logger.util'
export * from './with-swagger.util'
14 changes: 14 additions & 0 deletions packages/nestjs-shared/src/lib/util/with-custom-logger.util.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import { INestApplication } from '@nestjs/common'
import { LoggerService } from '../module/logger/service/logger.service'

/**
* Adds custom logger.
*
* @param app - The INestApplication instance.
* @returns The modified INestApplication instance.
*/
export const withCustomLogger = (app: INestApplication): INestApplication => {
app.useLogger(app.get(LoggerService))

return app
}

0 comments on commit 8a4acca

Please sign in to comment.