How to use the @phenyl/utils.visitEntitiesInResponseData function in @phenyl/utils

To help you get started, we’ve selected a few @phenyl/utils examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github phenyl / phenyl / modules / standards / src / remove-password-from-response-data.ts View on Github external
export function removePasswordFromResponseData(
  resData: GeneralUserEntityResponseData,
  passwordPropName: string
): GeneralUserEntityResponseData {
  return visitEntitiesInResponseData(
    resData,
    (entity: ProEntity): any => {
      if (!hasOwnNestedProperty(entity, passwordPropName)) return entity;
      const res = update(entity, { $unset: { [passwordPropName]: "" } });
      return res;
    }
  ) as GeneralUserEntityResponseData;
}