fix(auth): use env-configurable bcrypt rounds to prevent test timeout

HashedPassword.vo.spec.ts was timing out because SALT_ROUNDS=12 is too
expensive for the test runner. Make bcrypt rounds configurable via
BCRYPT_ROUNDS env var (default 12 for production), and set BCRYPT_ROUNDS=4
in vitest config for fast unit tests.

Co-Authored-By: Paperclip <noreply@paperclip.ing>
This commit is contained in:
Ho Ngoc Hai
2026-04-10 23:26:43 +07:00
parent 6ebacbc9bf
commit d4652fd0f9
3 changed files with 27 additions and 4 deletions

View File

@@ -6,7 +6,10 @@ interface HashedPasswordProps {
}
export class HashedPassword extends ValueObject<HashedPasswordProps> {
private static readonly SALT_ROUNDS = 12;
private static readonly SALT_ROUNDS = parseInt(
process.env.BCRYPT_ROUNDS ?? '12',
10,
);
private static readonly MIN_LENGTH = 8;
get value(): string {

View File

@@ -7,6 +7,9 @@ export default defineConfig({
environment: 'node',
include: ['src/**/*.spec.ts'],
exclude: ['src/**/*.integration.spec.ts', 'node_modules'],
env: {
BCRYPT_ROUNDS: '4',
},
},
resolve: {
alias: {