This commit is contained in:
Clusy committed 2026-08-06 04:47:05 +00:00
1 parent 62bdd6291e
commit 2d4eee2950
81 files changed
-10766

No files matched your search

-32
View File
@@ -1,32 +0,0 @@
import NodeCache from 'node-cache'
import { config } from '../config.js'
import type { TrueApiEnv } from '../config.js'
const cache = new NodeCache({
stdTTL: config.trueApi.tokenTTL / 1000,
checkperiod: 600,
})
function tokenKey(env: TrueApiEnv): string {
return `true_api_token_${env}`
}
export function getToken(env: TrueApiEnv): string | undefined {
return cache.get<string>(tokenKey(env))
}
export function setToken(env: TrueApiEnv, token: string): void {
cache.set(tokenKey(env), token)
}
export function hasToken(env: TrueApiEnv): boolean {
return cache.has(tokenKey(env))
}
export function getTokenTTL(env: TrueApiEnv): number | undefined {
return cache.getTtl(tokenKey(env))
}
export function invalidateToken(env: TrueApiEnv): void {
cache.del(tokenKey(env))
}