import { compare , hash } from 'bcryptjs' ; import { isEmpty } from 'lodash' ; import { Injectable } from '@nestjs/common' ; @ Injectable ( ) export class PasswordUtils { async compare ( password , hash ) { return compare ( password , hash ) ; } async hash ( password ) { if ( isEmpty ( password ) || password . length < 8 ) { throw new Error ( 'Password must be at least 8 characters.' ) ; } return hash ( password , 10 ) ; } }