Skip to content

Commit

Permalink
Refactor shared constants
Browse files Browse the repository at this point in the history
  • Loading branch information
wcalderipe committed Nov 13, 2024
1 parent 183737e commit 81771de
Show file tree
Hide file tree
Showing 25 changed files with 53 additions and 46 deletions.
10 changes: 7 additions & 3 deletions apps/armory/src/armory.constant.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
import { adminApiKeySecurity, clientIdSecurity, clientSecretSecurity } from '@narval/nestjs-shared'
import {
REQUEST_HEADER_CLIENT_ID,

Check failure on line 2 in apps/armory/src/armory.constant.ts

View workflow job for this annotation

GitHub Actions / Test

Module '"@narval/nestjs-shared"' has no exported member 'REQUEST_HEADER_CLIENT_ID'.
REQUEST_HEADER_CLIENT_SECRET,

Check failure on line 3 in apps/armory/src/armory.constant.ts

View workflow job for this annotation

GitHub Actions / Test

Module '"@narval/nestjs-shared"' has no exported member 'REQUEST_HEADER_CLIENT_SECRET'.
adminApiKeySecurity,
clientIdSecurity,
clientSecretSecurity
} from '@narval/nestjs-shared'
import { AssetId } from '@narval/policy-engine-shared'
import { ClassSerializerInterceptor, ValidationPipe } from '@nestjs/common'
import { APP_FILTER, APP_INTERCEPTOR, APP_PIPE } from '@nestjs/core'
Expand Down Expand Up @@ -49,8 +55,6 @@ export const DEFAULT_HTTP_MODULE_PROVIDERS = [
// Headers
//

export const REQUEST_HEADER_CLIENT_ID = 'x-client-id'
export const REQUEST_HEADER_CLIENT_SECRET = 'x-client-secret'
export const REQUEST_HEADER_API_KEY = 'x-api-key'

//
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { secret } from '@narval/nestjs-shared'
import { REQUEST_HEADER_CLIENT_ID, REQUEST_HEADER_CLIENT_SECRET, secret } from '@narval/nestjs-shared'

Check failure on line 1 in apps/armory/src/managed-data-store/shared/guard/data-store.guard.ts

View workflow job for this annotation

GitHub Actions / Test

Module '"@narval/nestjs-shared"' has no exported member 'REQUEST_HEADER_CLIENT_ID'.

Check failure on line 1 in apps/armory/src/managed-data-store/shared/guard/data-store.guard.ts

View workflow job for this annotation

GitHub Actions / Test

Module '"@narval/nestjs-shared"' has no exported member 'REQUEST_HEADER_CLIENT_SECRET'.
import { CanActivate, ExecutionContext, HttpStatus, Injectable } from '@nestjs/common'
import { REQUEST_HEADER_CLIENT_ID, REQUEST_HEADER_CLIENT_SECRET } from '../../../armory.constant'
import { ClientService } from '../../../client/core/service/client.service'
import { ApplicationException } from '../../../shared/exception/application.exception'

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { REQUEST_HEADER_CLIENT_ID } from '@narval/nestjs-shared'
import { ExecutionContext } from '@nestjs/common'
import { REQUEST_HEADER_CLIENT_ID } from '../../../../armory.constant'
import { factory } from '../../../decorator/client-id.decorator'

describe('clientId Decorator', () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { REQUEST_HEADER_CLIENT_ID } from '@narval/nestjs-shared'

Check failure on line 1 in apps/armory/src/shared/decorator/api-client-id-guard.decorator.ts

View workflow job for this annotation

GitHub Actions / Test

Module '"@narval/nestjs-shared"' has no exported member 'REQUEST_HEADER_CLIENT_ID'.
import { UseGuards, applyDecorators } from '@nestjs/common'
import { ApiHeader, ApiSecurity } from '@nestjs/swagger'
import { CLIENT_ID_SECURITY, REQUEST_HEADER_CLIENT_ID } from '../../armory.constant'
import { CLIENT_ID_SECURITY } from '../../armory.constant'
import { ClientIdGuard } from '../guard/client-id.guard'

export function ApiClientIdGuard() {
Expand Down
2 changes: 1 addition & 1 deletion apps/armory/src/shared/decorator/client-id.decorator.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { REQUEST_HEADER_CLIENT_ID } from '@narval/nestjs-shared'

Check failure on line 1 in apps/armory/src/shared/decorator/client-id.decorator.ts

View workflow job for this annotation

GitHub Actions / Test

Module '"@narval/nestjs-shared"' has no exported member 'REQUEST_HEADER_CLIENT_ID'.
import { BadRequestException, ExecutionContext, createParamDecorator } from '@nestjs/common'
import { REQUEST_HEADER_CLIENT_ID } from '../../armory.constant'

// eslint-disable-next-line @typescript-eslint/no-explicit-any
export const factory = (value: any, ctx: ExecutionContext) => {
Expand Down
2 changes: 1 addition & 1 deletion apps/armory/src/shared/guard/client-id.guard.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { REQUEST_HEADER_CLIENT_ID } from '@narval/nestjs-shared'

Check failure on line 1 in apps/armory/src/shared/guard/client-id.guard.ts

View workflow job for this annotation

GitHub Actions / Test

Module '"@narval/nestjs-shared"' has no exported member 'REQUEST_HEADER_CLIENT_ID'.
import { CanActivate, ExecutionContext, HttpStatus, Injectable } from '@nestjs/common'
import { REQUEST_HEADER_CLIENT_ID } from '../../armory.constant'
import { ClientService } from '../../client/core/service/client.service'
import { ApplicationException } from '../exception/application.exception'

Expand Down
3 changes: 1 addition & 2 deletions apps/armory/src/shared/guard/client-secret.guard.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { secret } from '@narval/nestjs-shared'
import { REQUEST_HEADER_CLIENT_ID, REQUEST_HEADER_CLIENT_SECRET, secret } from '@narval/nestjs-shared'

Check failure on line 1 in apps/armory/src/shared/guard/client-secret.guard.ts

View workflow job for this annotation

GitHub Actions / Test

Module '"@narval/nestjs-shared"' has no exported member 'REQUEST_HEADER_CLIENT_ID'.

Check failure on line 1 in apps/armory/src/shared/guard/client-secret.guard.ts

View workflow job for this annotation

GitHub Actions / Test

Module '"@narval/nestjs-shared"' has no exported member 'REQUEST_HEADER_CLIENT_SECRET'.
import { CanActivate, ExecutionContext, HttpStatus, Injectable } from '@nestjs/common'
import { REQUEST_HEADER_CLIENT_ID, REQUEST_HEADER_CLIENT_SECRET } from '../../armory.constant'
import { ClientService } from '../../client/core/service/client.service'
import { ApplicationException } from '../exception/application.exception'

Expand Down
14 changes: 8 additions & 6 deletions apps/policy-engine/src/engine/__test__/e2e/client.spec.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
import { ConfigModule, ConfigService } from '@narval/config-module'
import { EncryptionModuleOptionProvider } from '@narval/encryption-module'
import { LoggerModule, OpenTelemetryModule, secret } from '@narval/nestjs-shared'
import {
LoggerModule,
OpenTelemetryModule,
REQUEST_HEADER_CLIENT_ID,
REQUEST_HEADER_CLIENT_SECRET,
secret
} from '@narval/nestjs-shared'
import { DataStoreConfiguration, HttpSource, SourceType } from '@narval/policy-engine-shared'
import {
PrivateKey,
Expand All @@ -14,11 +20,7 @@ import request from 'supertest'
import { v4 as uuid } from 'uuid'
import { generatePrivateKey } from 'viem/accounts'
import { Config, load } from '../../../policy-engine.config'
import {
REQUEST_HEADER_API_KEY,
REQUEST_HEADER_CLIENT_ID,
REQUEST_HEADER_CLIENT_SECRET
} from '../../../policy-engine.constant'
import { REQUEST_HEADER_API_KEY } from '../../../policy-engine.constant'
import { TestPrismaService } from '../../../shared/module/persistence/service/test-prisma.service'
import { getTestRawAesKeyring } from '../../../shared/testing/encryption.testing'
import { Client } from '../../../shared/type/domain.type'
Expand Down
8 changes: 6 additions & 2 deletions apps/policy-engine/src/engine/__test__/e2e/evaluation.spec.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
import { ConfigModule, ConfigService } from '@narval/config-module'
import { EncryptionModuleOptionProvider } from '@narval/encryption-module'
import { LoggerModule, OpenTelemetryModule } from '@narval/nestjs-shared'
import {
LoggerModule,
OpenTelemetryModule,
REQUEST_HEADER_CLIENT_ID,
REQUEST_HEADER_CLIENT_SECRET
} from '@narval/nestjs-shared'
import {
Action,
Criterion,
Expand All @@ -24,7 +29,6 @@ import { generatePrivateKey } from 'viem/accounts'
import { sepolia } from 'viem/chains'
import { EngineService } from '../../../engine/core/service/engine.service'
import { Config, load } from '../../../policy-engine.config'
import { REQUEST_HEADER_CLIENT_ID, REQUEST_HEADER_CLIENT_SECRET } from '../../../policy-engine.constant'
import { KeyValueRepository } from '../../../shared/module/key-value/core/repository/key-value.repository'
import { InMemoryKeyValueRepository } from '../../../shared/module/key-value/persistence/repository/in-memory-key-value.repository'
import { TestPrismaService } from '../../../shared/module/persistence/service/test-prisma.service'
Expand Down
12 changes: 8 additions & 4 deletions apps/policy-engine/src/policy-engine.constant.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,17 @@
import { RawAesWrappingSuiteIdentifier } from '@aws-crypto/client-node'
import { adminApiKeySecurity, clientIdSecurity, clientSecretSecurity } from '@narval/nestjs-shared'
import {
REQUEST_HEADER_CLIENT_ID,

Check failure on line 3 in apps/policy-engine/src/policy-engine.constant.ts

View workflow job for this annotation

GitHub Actions / Test

Module '"@narval/nestjs-shared"' has no exported member 'REQUEST_HEADER_CLIENT_ID'.
REQUEST_HEADER_CLIENT_SECRET,

Check failure on line 4 in apps/policy-engine/src/policy-engine.constant.ts

View workflow job for this annotation

GitHub Actions / Test

Module '"@narval/nestjs-shared"' has no exported member 'REQUEST_HEADER_CLIENT_SECRET'.
adminApiKeySecurity,
clientIdSecurity,
clientSecretSecurity
} from '@narval/nestjs-shared'

//
// Headers
//

export const REQUEST_HEADER_API_KEY = 'x-api-key'
export const REQUEST_HEADER_CLIENT_ID = 'x-client-id'
export const REQUEST_HEADER_CLIENT_SECRET = 'x-client-secret'
export const REQUEST_HEADER_SESSION_ID = 'x-session-id'

//
Expand All @@ -23,7 +27,7 @@ export const ENCRYPTION_WRAPPING_SUITE = RawAesWrappingSuiteIdentifier.AES256_GC
//

export const ADMIN_SECURITY = adminApiKeySecurity(REQUEST_HEADER_API_KEY)
export const CLIENT_ID_SECURITY = clientIdSecurity(REQUEST_HEADER_CLIENT_SECRET)
export const CLIENT_ID_SECURITY = clientIdSecurity(REQUEST_HEADER_CLIENT_ID)
export const CLIENT_SECRET_SECURITY = clientSecretSecurity(REQUEST_HEADER_CLIENT_SECRET)

//
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { REQUEST_HEADER_CLIENT_ID } from '@narval/nestjs-shared'
import { ExecutionContext } from '@nestjs/common'
import { REQUEST_HEADER_CLIENT_ID } from '../../../../policy-engine.constant'
import { factory } from '../../client-id.decorator'

describe('ClientId Decorator', () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
import { REQUEST_HEADER_CLIENT_ID, REQUEST_HEADER_CLIENT_SECRET } from '@narval/nestjs-shared'

Check failure on line 1 in apps/policy-engine/src/shared/decorator/client-guard.decorator.ts

View workflow job for this annotation

GitHub Actions / Test

Module '"@narval/nestjs-shared"' has no exported member 'REQUEST_HEADER_CLIENT_ID'.

Check failure on line 1 in apps/policy-engine/src/shared/decorator/client-guard.decorator.ts

View workflow job for this annotation

GitHub Actions / Test

Module '"@narval/nestjs-shared"' has no exported member 'REQUEST_HEADER_CLIENT_SECRET'.
import { UseGuards, applyDecorators } from '@nestjs/common'
import { ApiHeader, ApiSecurity } from '@nestjs/swagger'
import {
CLIENT_ID_SECURITY,
CLIENT_SECRET_SECURITY,
REQUEST_HEADER_CLIENT_ID,
REQUEST_HEADER_CLIENT_SECRET
} from '../../policy-engine.constant'
import { CLIENT_ID_SECURITY, CLIENT_SECRET_SECURITY } from '../../policy-engine.constant'
import { ClientSecretGuard } from '../guard/client-secret.guard'

export function ClientGuard() {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
import { secret } from '@narval/nestjs-shared'
import { REQUEST_HEADER_CLIENT_ID, REQUEST_HEADER_CLIENT_SECRET, secret } from '@narval/nestjs-shared'
import { HttpSource, SourceType } from '@narval/policy-engine-shared'
import { Alg, privateKeyToJwk } from '@narval/signature'
import { ExecutionContext } from '@nestjs/common'
import { mock } from 'jest-mock-extended'
import { generatePrivateKey } from 'viem/accounts'
import { ClientService } from '../../../../engine/core/service/client.service'
import { REQUEST_HEADER_CLIENT_ID, REQUEST_HEADER_CLIENT_SECRET } from '../../../../policy-engine.constant'
import { ApplicationException } from '../../../exception/application.exception'
import { Client } from '../../../type/domain.type'
import { ClientSecretGuard } from '../../client-secret.guard'
Expand Down
3 changes: 1 addition & 2 deletions apps/policy-engine/src/shared/guard/client-secret.guard.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { secret } from '@narval/nestjs-shared'
import { REQUEST_HEADER_CLIENT_ID, REQUEST_HEADER_CLIENT_SECRET, secret } from '@narval/nestjs-shared'

Check failure on line 1 in apps/policy-engine/src/shared/guard/client-secret.guard.ts

View workflow job for this annotation

GitHub Actions / Test

Module '"@narval/nestjs-shared"' has no exported member 'REQUEST_HEADER_CLIENT_ID'.

Check failure on line 1 in apps/policy-engine/src/shared/guard/client-secret.guard.ts

View workflow job for this annotation

GitHub Actions / Test

Module '"@narval/nestjs-shared"' has no exported member 'REQUEST_HEADER_CLIENT_SECRET'.
import { CanActivate, ExecutionContext, HttpStatus, Injectable } from '@nestjs/common'
import { ClientService } from '../../engine/core/service/client.service'
import { REQUEST_HEADER_CLIENT_ID, REQUEST_HEADER_CLIENT_SECRET } from '../../policy-engine.constant'
import { ApplicationException } from '../exception/application.exception'

@Injectable()
Expand Down
1 change: 0 additions & 1 deletion apps/vault/src/main.constant.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import { RawAesWrappingSuiteIdentifier } from '@aws-crypto/client-node'
import { adminApiKeySecurity, gnapSecurity } from '@narval/nestjs-shared'

export const REQUEST_HEADER_API_KEY = 'x-api-key'
export const REQUEST_HEADER_CLIENT_ID = 'x-client-id'
export const REQUEST_HEADER_AUTHORIZATION = 'Authorization'

export const ENCRYPTION_KEY_NAMESPACE = 'armory.vault'
Expand Down
2 changes: 1 addition & 1 deletion apps/vault/src/shared/decorator/client-id.decorator.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { REQUEST_HEADER_CLIENT_ID } from '@narval/nestjs-shared'

Check failure on line 1 in apps/vault/src/shared/decorator/client-id.decorator.ts

View workflow job for this annotation

GitHub Actions / Test

Module '"@narval/nestjs-shared"' has no exported member 'REQUEST_HEADER_CLIENT_ID'.
import { createParamDecorator, ExecutionContext } from '@nestjs/common'
import { REQUEST_HEADER_CLIENT_ID } from '../../main.constant'

export const ClientId = createParamDecorator((_data: unknown, context: ExecutionContext): string => {
const req = context.switchToHttp().getRequest()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { REQUEST_HEADER_CLIENT_ID } from '@narval/nestjs-shared'
import { ExecutionContext } from '@nestjs/common'
import { Test } from '@nestjs/testing'
import { Request } from 'express'
import { MockProxy, mock } from 'jest-mock-extended'
import { REQUEST_HEADER_CLIENT_ID } from '../../../../main.constant'
import { NonceService } from '../../../../vault/core/service/nonce.service'
import { ApplicationException } from '../../../exception/application.exception'
import { NonceGuard } from '../../nonce.guard'
Expand Down
2 changes: 1 addition & 1 deletion apps/vault/src/shared/guard/authorization.guard.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { ConfigService } from '@narval/config-module'
import { REQUEST_HEADER_CLIENT_ID } from '@narval/nestjs-shared'

Check failure on line 2 in apps/vault/src/shared/guard/authorization.guard.ts

View workflow job for this annotation

GitHub Actions / Test

Module '"@narval/nestjs-shared"' has no exported member 'REQUEST_HEADER_CLIENT_ID'.
import { JwtVerifyOptions, publicKeySchema, verifyJwsd, verifyJwt } from '@narval/signature'
import { CanActivate, ExecutionContext, HttpStatus, Injectable } from '@nestjs/common'
import { Reflector } from '@nestjs/core'
import { z } from 'zod'
import { ClientService } from '../../client/core/service/client.service'
import { Config } from '../../main.config'
import { REQUEST_HEADER_CLIENT_ID } from '../../main.constant'
import { PermissionGuard } from '../decorator/permission-guard.decorator'
import { ApplicationException } from '../exception/application.exception'
import { Client } from '../type/domain.type'
Expand Down
2 changes: 1 addition & 1 deletion apps/vault/src/shared/guard/nonce.guard.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { REQUEST_HEADER_CLIENT_ID } from '@narval/nestjs-shared'

Check failure on line 1 in apps/vault/src/shared/guard/nonce.guard.ts

View workflow job for this annotation

GitHub Actions / Test

Module '"@narval/nestjs-shared"' has no exported member 'REQUEST_HEADER_CLIENT_ID'.
import { CanActivate, ExecutionContext, HttpStatus, Injectable } from '@nestjs/common'
import { Request } from 'express'
import { get } from 'lodash/fp'
import { REQUEST_HEADER_CLIENT_ID } from '../../main.constant'
import { NonceService } from '../../vault/core/service/nonce.service'
import { ApplicationException } from '../exception/application.exception'

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Permission } from '@narval/armory-sdk'
import { REQUEST_HEADER_CLIENT_ID } from '@narval/nestjs-shared'

Check failure on line 2 in apps/vault/src/vault/http/rest/controller/account.controller.ts

View workflow job for this annotation

GitHub Actions / Test

Module '"@narval/nestjs-shared"' has no exported member 'REQUEST_HEADER_CLIENT_ID'.
import { Body, Controller, Get, HttpStatus, Post } from '@nestjs/common'
import { ApiHeader, ApiOperation, ApiResponse, ApiTags } from '@nestjs/swagger'
import { REQUEST_HEADER_CLIENT_ID } from '../../../../main.constant'
import { ClientId } from '../../../../shared/decorator/client-id.decorator'
import { PermissionGuard } from '../../../../shared/decorator/permission-guard.decorator'
import { ApplicationException } from '../../../../shared/exception/application.exception'
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Permission } from '@narval/armory-sdk'
import { REQUEST_HEADER_CLIENT_ID } from '@narval/nestjs-shared'

Check failure on line 2 in apps/vault/src/vault/http/rest/controller/encryption-key.controller.ts

View workflow job for this annotation

GitHub Actions / Test

Module '"@narval/nestjs-shared"' has no exported member 'REQUEST_HEADER_CLIENT_ID'.
import { Controller, HttpStatus, Post } from '@nestjs/common'
import { ApiHeader, ApiOperation, ApiResponse, ApiTags } from '@nestjs/swagger'
import { REQUEST_HEADER_CLIENT_ID } from '../../../../main.constant'
import { ClientId } from '../../../../shared/decorator/client-id.decorator'
import { PermissionGuard } from '../../../../shared/decorator/permission-guard.decorator'
import { ImportService } from '../../../core/service/import.service'
Expand Down
3 changes: 1 addition & 2 deletions apps/vault/src/vault/http/rest/controller/sign.controller.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import { ApiGnapSecurity } from '@narval/nestjs-shared'
import { ApiGnapSecurity, REQUEST_HEADER_CLIENT_ID } from '@narval/nestjs-shared'

Check failure on line 1 in apps/vault/src/vault/http/rest/controller/sign.controller.ts

View workflow job for this annotation

GitHub Actions / Test

Module '"@narval/nestjs-shared"' has no exported member 'REQUEST_HEADER_CLIENT_ID'.
import { SignableRequest } from '@narval/policy-engine-shared'
import { Body, Controller, HttpStatus, Post, UseGuards } from '@nestjs/common'
import { ApiHeader, ApiOperation, ApiResponse, ApiTags } from '@nestjs/swagger'
import { REQUEST_HEADER_CLIENT_ID } from '../../../../main.constant'
import { ClientId } from '../../../../shared/decorator/client-id.decorator'
import { AuthorizationGuard } from '../../../../shared/guard/authorization.guard'
import { NonceGuard } from '../../../../shared/guard/nonce.guard'
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Permission } from '@narval/armory-sdk'
import { REQUEST_HEADER_CLIENT_ID } from '@narval/nestjs-shared'

Check failure on line 2 in apps/vault/src/vault/http/rest/controller/wallet.controller.ts

View workflow job for this annotation

GitHub Actions / Test

Module '"@narval/nestjs-shared"' has no exported member 'REQUEST_HEADER_CLIENT_ID'.
import { Body, Controller, Get, HttpStatus, Post } from '@nestjs/common'
import { ApiHeader, ApiOperation, ApiResponse, ApiTags } from '@nestjs/swagger'
import { REQUEST_HEADER_CLIENT_ID } from '../../../../main.constant'
import { ClientId } from '../../../../shared/decorator/client-id.decorator'
import { PermissionGuard } from '../../../../shared/decorator/permission-guard.decorator'
import { AdminService } from '../../../core/service/admin.service'
Expand Down
1 change: 1 addition & 0 deletions packages/nestjs-shared/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
export * from './lib/constant'

Check failure on line 1 in packages/nestjs-shared/src/index.ts

View workflow job for this annotation

GitHub Actions / Build and test

Cannot find module './lib/constant' or its corresponding type declarations.

Check failure on line 1 in packages/nestjs-shared/src/index.ts

View workflow job for this annotation

GitHub Actions / Test

Cannot find module './lib/constant' or its corresponding type declarations.

Check failure on line 1 in packages/nestjs-shared/src/index.ts

View workflow job for this annotation

GitHub Actions / Test

Cannot find module './lib/constant' or its corresponding type declarations.
export * from './lib/decorator'
export * from './lib/dto'
export * from './lib/middleware'
Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,18 @@
import { Inject, Injectable, NestMiddleware } from '@nestjs/common'
import { NextFunction, Request, Response } from 'express'
import { OTEL_ATTR_CLIENT_ID, REQUEST_HEADER_CLIENT_ID } from '../constant'

Check failure on line 3 in packages/nestjs-shared/src/lib/middleware/track-client-id.middleware.ts

View workflow job for this annotation

GitHub Actions / Build and test

Cannot find module '../constant' or its corresponding type declarations.

Check failure on line 3 in packages/nestjs-shared/src/lib/middleware/track-client-id.middleware.ts

View workflow job for this annotation

GitHub Actions / Test

Cannot find module '../constant' or its corresponding type declarations.

Check failure on line 3 in packages/nestjs-shared/src/lib/middleware/track-client-id.middleware.ts

View workflow job for this annotation

GitHub Actions / Test

Cannot find module '../constant' or its corresponding type declarations.
import { TraceService } from '../module/open-telemetry'

@Injectable()
export class TrackClientIdMiddleware implements NestMiddleware {
constructor(@Inject(TraceService) private traceService: TraceService) {}

use(request: Request, _response: Response, next: NextFunction): void {
const clientId = request.headers['x-client-id']
const clientId = request.headers[REQUEST_HEADER_CLIENT_ID]

if (clientId) {
this.traceService.setAttributesOnActiveSpan({
'domain.client.id': clientId
[OTEL_ATTR_CLIENT_ID]: clientId
})
}

Expand Down

0 comments on commit 81771de

Please sign in to comment.