feat: track when API tokens were last used

This commit is contained in:
Catalin Pit
2026-08-18 11:39:12 +03:00
parent 9bab1cddb3
commit 143ffeeb7e
6 changed files with 40 additions and 10 deletions
@@ -96,6 +96,17 @@ export const getApiTokenByToken = async ({ token, bypassRateLimit = false }: Get
});
}
void prisma.apiToken
.update({
where: {
id: apiToken.id,
},
data: {
lastUsedAt: new Date(),
},
})
.catch(() => null);
return {
...apiToken,
user,
@@ -22,6 +22,7 @@ export const getApiTokens = async ({ userId, teamId }: GetApiTokensOptions) => {
name: true,
createdAt: true,
expires: true,
lastUsedAt: true,
},
orderBy: {
createdAt: 'desc',