UNPKG

@elsikora/nestjs-crud-automator

Version:

A library for automating the creation of CRUD operations in NestJS.

24 lines (21 loc) 1.11 kB
'use strict'; /** * Determines if a property should be exposed for the current authentication guard * @param {EApiRouteType} method - The API route type (GET, POST, etc.) * @param {TApiPropertyDescribeProperties} propertyMetadata - The property's metadata * @param {EApiDtoType} dtoType - The DTO type (request, response, etc.) * @param {Type<IAuthGuard>} currentGuard - The current authentication guard * @returns {boolean} True if the property should be exposed, false otherwise */ function DtoIsPropertyExposedForGuard(method, propertyMetadata, dtoType, currentGuard) { const properties = propertyMetadata.properties?.[method]; if (!properties?.[dtoType]?.guard || !currentGuard) { return true; } const { guards, isInverse = false } = properties?.[dtoType]?.guard ?? {}; const guardArray = Array.isArray(guards) ? guards : [guards]; const isGuardMatch = guardArray.includes(currentGuard); return isInverse ? !isGuardMatch : isGuardMatch; } exports.DtoIsPropertyExposedForGuard = DtoIsPropertyExposedForGuard; //# sourceMappingURL=exposed-for-guard.utility.js.map