MCPcopy
hub / github.com/tiagozip/cap / loadCustomTokens

Function loadCustomTokens

checkpoints/express/index.js:28–48  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

26 fs.mkdir(dirname(options.tokens_store_path), { recursive: true });
27
28 async function loadCustomTokens() {
29 try {
30 const stats = await fs.stat(options.tokens_store_path);
31
32 if (tokensCache && stats.mtime.getTime() <= cacheLastModified) {
33 return tokensCache;
34 }
35
36 tokensCache = JSON.parse(
37 await fs.readFile(options.tokens_store_path, "utf-8"),
38 );
39 cacheLastModified = Date.now();
40
41 return tokensCache;
42 } catch {
43 tokensCache = {};
44 cacheLastModified = Date.now();
45
46 return tokensCache;
47 }
48 }
49
50 async function saveCustomTokens(tokens) {
51 await fs.writeFile(options.tokens_store_path, JSON.stringify(tokens));

Callers 3

storeCustomTokenFunction · 0.70
validateCustomTokenFunction · 0.70
cleanupExpiredTokensFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected