Skip to content

Commit

Permalink
chore(framework, api): Remove deprecated X- prefixed headers (#6783)
Browse files Browse the repository at this point in the history
  • Loading branch information
rifont authored Oct 28, 2024
1 parent bd2f04d commit c8c51d0
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 13 deletions.
11 changes: 5 additions & 6 deletions apps/api/src/app/bridge/bridge.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import {
UseInterceptors,
} from '@nestjs/common';

import { HttpHeaderKeysEnum } from '@novu/framework/internal';
import { ControlValuesLevelEnum, UserSessionData, WorkflowOriginEnum, WorkflowTypeEnum } from '@novu/shared';
import { AnalyticsService, ExternalApiAccessible, UserAuthGuard, UserSession } from '@novu/application-generic';
import { ControlValuesRepository, EnvironmentRepository, NotificationTemplateRepository } from '@novu/dal';
Expand Down Expand Up @@ -84,14 +85,12 @@ export class BridgeController {
@ExternalApiAccessible()
@UseGuards(UserAuthGuard)
async createBridgesByDiscovery(
@Headers('x-novu-anonymous') anonymousIdDeprecated: string,
@Headers('novu-anonymous') anonymousId: string,
@Headers(HttpHeaderKeysEnum.NOVU_ANONYMOUS) anonymousId: string,
@UserSession() user: UserSessionData,
@Body() body: CreateBridgeRequestDto,
@Query('source') source?: string
): Promise<CreateBridgeResponseDto> {
const chosenAnonymousIdHeader = anonymousId ?? anonymousIdDeprecated;
if (chosenAnonymousIdHeader && chosenAnonymousIdHeader !== 'null') {
if (anonymousId) {
this.analyticsService.alias(anonymousId, user._id);
}

Expand All @@ -111,7 +110,7 @@ export class BridgeController {
@ExternalApiAccessible()
@UseGuards(UserAuthGuard)
async createDiscoverySoft(
@Headers('x-novu-anonymous') anonymousId: string,
@Headers(HttpHeaderKeysEnum.NOVU_ANONYMOUS) anonymousId: string,
@UserSession() user: UserSessionData,
@Body() body: CreateBridgeRequestDto
): Promise<CreateBridgeResponseDto> {
Expand All @@ -121,7 +120,7 @@ export class BridgeController {
throw new BadRequestException('Bridge URL not found');
}

if (anonymousId && anonymousId !== 'null') {
if (anonymousId) {
this.analyticsService.alias(anonymousId, user._id);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,6 @@ export class ExecuteBridgeRequest {
return {
[HttpRequestHeaderKeysEnum.BYPASS_TUNNEL_REMINDER]: 'true',
[HttpRequestHeaderKeysEnum.CONTENT_TYPE]: 'application/json',
[HttpHeaderKeysEnum.NOVU_SIGNATURE_DEPRECATED]: novuSignatureHeader,
[HttpHeaderKeysEnum.NOVU_SIGNATURE]: novuSignatureHeader,
};
}
Expand Down
2 changes: 0 additions & 2 deletions packages/framework/src/constants/http-headers.constants.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
export enum HttpHeaderKeysEnum {
NOVU_SIGNATURE = 'novu-signature',
NOVU_ANONYMOUS = 'novu-anonymous',
NOVU_SIGNATURE_DEPRECATED = 'x-novu-signature',
NOVU_ANONYMOUS_DEPRECATED = 'x-novu-anonymous',
NOVU_FRAMEWORK_SDK = 'novu-framework-sdk',
NOVU_FRAMEWORK_SERVER = 'novu-framework-server',
NOVU_FRAMEWORK_VERSION = 'novu-framework-version',
Expand Down
5 changes: 1 addition & 4 deletions packages/framework/src/handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -135,10 +135,7 @@ export class NovuRequestHandler<Input extends any[] = any[], Output = any> {
const action = url.searchParams.get(HttpQueryKeysEnum.ACTION) || GetActionEnum.HEALTH_CHECK;
const workflowId = url.searchParams.get(HttpQueryKeysEnum.WORKFLOW_ID) || '';
const stepId = url.searchParams.get(HttpQueryKeysEnum.STEP_ID) || '';
const signatureHeader =
(await actions.headers(HttpHeaderKeysEnum.NOVU_SIGNATURE)) ||
(await actions.headers(HttpHeaderKeysEnum.NOVU_SIGNATURE_DEPRECATED)) ||
'';
const signatureHeader = (await actions.headers(HttpHeaderKeysEnum.NOVU_SIGNATURE)) || '';

let body: Record<string, unknown> = {};
try {
Expand Down

0 comments on commit c8c51d0

Please sign in to comment.