MORE UNIT TESTS - approc 90% before - 95% now?
All checks were successful
Deploy to Test Environment / deploy-to-test (push) Successful in 45m25s

This commit is contained in:
2025-12-17 20:57:28 -08:00
parent 6c17f202ed
commit c623cddfb5
53 changed files with 2835 additions and 973 deletions

View File

@@ -444,6 +444,23 @@ export class UserRepository {
}
}
/**
* Deletes all expired password reset tokens from the database.
* This is intended for a periodic cleanup job.
* @returns A promise that resolves to the number of deleted tokens.
*/
async deleteExpiredResetTokens(logger: Logger): Promise<number> {
try {
const res = await this.db.query(
"DELETE FROM public.password_reset_tokens WHERE expires_at < NOW()"
);
logger.info(`[DB deleteExpiredResetTokens] Deleted ${res.rowCount ?? 0} expired password reset tokens.`);
return res.rowCount ?? 0;
} catch (error) {
logger.error({ err: error }, 'Database error in deleteExpiredResetTokens');
throw new Error('Failed to delete expired password reset tokens.');
}
}
/**
* Creates a following relationship between two users.
* @param followerId The ID of the user who is following.