Skip to content

Commit e164062

Browse files
committed
refactor: rename variables
1 parent 235d568 commit e164062

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

lib/index.js

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -135,11 +135,11 @@ class ErrsolePostgres extends EventEmitter {
135135
}
136136

137137
async ensureLogsTTL () {
138-
const defaultTTL = 30 * 24 * 60 * 60 * 1000; // 30 days in milliseconds
138+
const DEFAULT_LOGS_TTL = 30 * 24 * 60 * 60 * 1000; // 30 days in milliseconds
139139
try {
140140
const configResult = await this.getConfig('logsTTL');
141141
if (!configResult.item) {
142-
await this.setConfig('logsTTL', defaultTTL.toString());
142+
await this.setConfig('logsTTL', DEFAULT_LOGS_TTL.toString());
143143
}
144144
} catch (err) {
145145
console.error(err);
@@ -498,8 +498,8 @@ class ErrsolePostgres extends EventEmitter {
498498
const values = [user.name, user.email, hashedPassword, user.role];
499499

500500
try {
501-
const results = await this.pool.query(query, values);
502-
return { item: { id: results.rows[0].id, name: user.name, email: user.email, role: user.role } };
501+
const { rows } = await this.pool.query(query, values);
502+
return { item: { id: rows[0].id, name: user.name, email: user.email, role: user.role } };
503503
} catch (err) {
504504
if (err.code === '23505') {
505505
throw new Error('A user with the provided email already exists.');
@@ -644,9 +644,9 @@ class ErrsolePostgres extends EventEmitter {
644644

645645
const hashedPassword = await bcrypt.hash(newPassword, 10);
646646
const updateQuery = 'UPDATE errsole_users SET hashed_password = $1 WHERE email = $2';
647-
const updateResults = await this.pool.query(updateQuery, [hashedPassword, email]);
647+
const updateResult = await this.pool.query(updateQuery, [hashedPassword, email]);
648648

649-
if (updateResults.rowCount === 0) {
649+
if (updateResult.rowCount === 0) {
650650
throw new Error('Password update failed.');
651651
}
652652

@@ -667,8 +667,8 @@ class ErrsolePostgres extends EventEmitter {
667667
if (!id) throw new Error('User ID is required.');
668668

669669
const query = 'DELETE FROM errsole_users WHERE id = $1';
670-
const results = await this.pool.query(query, [id]);
671-
if (results.rowCount === 0) throw new Error('User not found.');
670+
const result = await this.pool.query(query, [id]);
671+
if (result.rowCount === 0) throw new Error('User not found.');
672672
return {};
673673
}
674674
}

0 commit comments

Comments
 (0)