MCPcopy Index your code
hub / github.com/simstudioai/sim / updateApiKeyLastUsed

Function updateApiKeyLastUsed

apps/sim/lib/api-key/service.ts:151–166  ·  view source on GitHub ↗
(keyId: string)

Source from the content-addressed store, hash-verified

149 * last-used tracking.
150 */
151export async function updateApiKeyLastUsed(keyId: string): Promise<void> {
152 try {
153 const staleBefore = new Date(Date.now() - LAST_USED_STALENESS_WINDOW_MS)
154 await db
155 .update(apiKeyTable)
156 .set({ lastUsed: new Date() })
157 .where(
158 and(
159 eq(apiKeyTable.id, keyId),
160 or(isNull(apiKeyTable.lastUsed), lt(apiKeyTable.lastUsed, staleBefore))
161 )
162 )
163 } catch (error) {
164 logger.error('Error updating API key last used:', error)
165 }
166}

Callers 4

service.test.tsFile · 0.90
checkHybridAuthFunction · 0.90
validateWorkflowAccessFunction · 0.90
authenticateV1RequestFunction · 0.90

Calls 3

errorMethod · 0.80
setMethod · 0.65
eqFunction · 0.50

Tested by

no test coverage detected