Reorganize repo structure and standards references

This commit is contained in:
david committed 2026-06-29 05:03:42 +02:00
1 parent 3cb93a81be
commit be2054274d
5885 files changed
+2588 -195

No files matched your search

@@ -0,0 +1,33 @@
import { createSharedStore, type SharedStore } from "@toolctrl/shared-store";
/**
* Singleton SharedStore for the API process. All in-process Map-backed
* stores migrated as part of task #38 receive their `SharedStore` from
* this module so the underlying Redis connection (or memory fallback)
* is reused across the API lifetime.
*/
let cachedStore: SharedStore | null = null;
let factory: () => SharedStore = () => createSharedStore({ namespace: "api", redisUrl: process.env.REDIS_URL });
export function getSharedStore(): SharedStore {
if (cachedStore === null) {
cachedStore = factory();
}
return cachedStore;
}
/**
* Test seam: override the factory and clear the cached instance. Tests
* call this to inject a SharedStore that uses an in-memory adapter or a
* specific Redis test container.
*/
export function __setSharedStoreFactoryForTests(next: () => SharedStore): void {
factory = next;
cachedStore = null;
}
/** Test seam: reset to the default factory and drop the cached instance. */
export function __resetSharedStoreForTests(): void {
factory = () => createSharedStore({ namespace: "api", redisUrl: process.env.REDIS_URL });
cachedStore = null;
}