From 3e08a647a58f88628c2fde44a8cbf563d7a0c5dd Mon Sep 17 00:00:00 2001 From: soufiane Date: Sat, 22 Nov 2025 17:53:31 +0100 Subject: [PATCH] feat: add updatedAt field to user profile endpoints MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Add updated_at to SELECT query in getProfile - Add updatedAt to response in getProfile - Auto-update updated_at timestamp in updateProfile - Add updated_at to RETURNING clause in updateProfile - Include isVerified, createdAt, updatedAt in updateProfile response 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude --- src/controllers/user.controller.js | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/controllers/user.controller.js b/src/controllers/user.controller.js index 79bc13d7..da22352d 100644 --- a/src/controllers/user.controller.js +++ b/src/controllers/user.controller.js @@ -13,7 +13,7 @@ export const getProfile = asyncHandler(async (req, res) => { const userId = req.user.id; const result = await pool.query( - `SELECT id, email, first_name, last_name, phone, address, city, postal_code, role, is_verified, created_at + `SELECT id, email, first_name, last_name, phone, address, city, postal_code, role, is_verified, created_at, updated_at FROM users WHERE id = $1`, [userId] ); @@ -34,6 +34,7 @@ export const getProfile = asyncHandler(async (req, res) => { role: user.role, isVerified: user.is_verified, createdAt: user.created_at, + updatedAt: user.updated_at, }, }); }); @@ -83,13 +84,15 @@ export const updateProfile = asyncHandler(async (req, res) => { }); } + // Ajouter updated_at à la mise à jour + updates.push(`updated_at = NOW()`); values.push(userId); const query = ` UPDATE users SET ${updates.join(', ')} WHERE id = $${paramCount} - RETURNING id, email, first_name, last_name, phone, address, city, postal_code, role + RETURNING id, email, first_name, last_name, phone, address, city, postal_code, role, is_verified, created_at, updated_at `; const result = await pool.query(query, values); @@ -108,6 +111,9 @@ export const updateProfile = asyncHandler(async (req, res) => { city: user.city, postalCode: user.postal_code, role: user.role, + isVerified: user.is_verified, + createdAt: user.created_at, + updatedAt: user.updated_at, }, }); });