diff --git a/node-api/src/routes/api.js b/node-api/src/routes/api.js
index 5e958ed..401b1b6 100644
--- a/node-api/src/routes/api.js
+++ b/node-api/src/routes/api.js
@@ -162,4 +162,18 @@ router.get('/devices', async (_req, res) => {
}
});
+router.patch('/devices/:id', async (req, res) => {
+ try {
+ const id = parseInt(String(req.params.id), 10);
+ if (!Number.isInteger(id) || id <= 0) return res.status(400).json({ ok: false, error: 'invalid_id' });
+ const { nombre, descripcion } = req.body || {};
+ const { rowCount } = await pool.query('UPDATE dispositivos SET nombre = $2, descripcion = $3, last_seen = NOW() WHERE id = $1', [id, nombre != null ? String(nombre) : null, descripcion != null ? String(descripcion) : null]);
+ if (rowCount === 0) return res.status(404).json({ ok: false, error: 'not_found' });
+ res.json({ ok: true });
+ } catch (e) {
+ console.error('PATCH /api/devices/:id error:', e?.message || e);
+ res.status(500).json({ ok: false, error: 'db_error' });
+ }
+});
+
export default router;