refactor(logging): replace console usage with logger

This commit is contained in:
William Valentin
2025-09-23 12:19:15 -07:00
parent 16bd4a8b20
commit 10d1de91fe
11 changed files with 76 additions and 44 deletions

View File

@@ -3,6 +3,8 @@ import { MockDatabaseStrategy } from './MockDatabaseStrategy';
import { ProductionDatabaseStrategy } from './ProductionDatabaseStrategy';
import { DatabaseStrategy } from './types';
import { AccountStatus } from '../auth/auth.constants';
import { hashPassword } from '../auth/password.service';
import { logger } from '../logging';
/**
* Consolidated Database Service
@@ -30,9 +32,9 @@ export class DatabaseService implements DatabaseStrategy {
try {
return new ProductionDatabaseStrategy();
} catch (error) {
console.warn(
'Production CouchDB service not available, falling back to mock:',
error
logger.db.warn(
'Production CouchDB service not available, falling back to mock',
error as Error
);
return new MockDatabaseStrategy();
}
@@ -188,9 +190,10 @@ export class DatabaseService implements DatabaseStrategy {
async changeUserPassword(userId: string, newPassword: string) {
const user = await this.strategy.getUserById(userId);
if (!user) throw new Error('User not found');
const hashedPassword = await hashPassword(newPassword);
return this.strategy.updateUser({
...user,
password: newPassword,
password: hashedPassword,
});
}