Files
lislgosms/api/src/common/tenant-id.decorator.ts
T

8 lines
386 B
TypeScript

import { createParamDecorator, ExecutionContext } from '@nestjs/common';
export const TenantId = createParamDecorator((_: unknown, context: ExecutionContext) => {
const request = context.switchToHttp().getRequest<{ header(name: string): string | undefined }>();
const value = request.header('x-tenant-id');
return value && value.trim().length > 0 ? value.trim() : undefined;
});