translated error

This commit is contained in:
2024-10-31 08:29:56 +03:00
parent c950882e0e
commit d4233c72f5
2 changed files with 3 additions and 1 deletions

View File

@@ -6,6 +6,7 @@ import errorHandler from '../utils/pgerrorhandler.js';
class UserService {
async create(username, password) {
if (await this.getByUsername(username)) throw new customError(`Such user exists`, responseCodes.responses.user.duplicate);
await db.query("INSERT INTO users (username, password) VALUES ($1, $2)", [username, bcrypt.hashSync(password, 12)]).catch((e) => {
errorHandler(e, "user");
})