refactored backend

This commit is contained in:
2025-11-23 19:33:12 +01:00
parent 8ce882a745
commit a78118da8d
2 changed files with 11 additions and 3 deletions

View File

@@ -17,7 +17,15 @@ export const verifyAPIKeyDB = async (apiKey) => {
[apiKey]
);
if (result.length > 0) {
return { valid: true };
const [lastUsed] = await pool.query(
"UPDATE apiKeys SET last_used_at = NOW() WHERE api_key = ?;",
[apiKey]
);
if (lastUsed.affectedRows > 0) {
return { valid: true };
} else {
return { valid: false };
}
} else {
return { valid: false };
}