Revert "12"

This reverts commit 2d4eee2950.
This commit is contained in:
Your Name committed 2026-08-06 04:52:21 +00:00
1 parent 2d4eee2950
commit 3a217f0dd0
81 files changed
+10766

No files matched your search

+32
View File
@@ -0,0 +1,32 @@
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))
}