Initial commit

This commit is contained in:
2026-05-25 08:22:12 +07:00
commit a152c99cce
154 changed files with 39033 additions and 0 deletions

View File

@ -0,0 +1,26 @@
const store = new Map();
export function makeIdempotencyKey(scope, key) {
return `${scope}:${key}`;
}
export function readIdempotency(scope, key) {
const entry = store.get(makeIdempotencyKey(scope, key));
if (!entry) {
return null;
}
if (entry.expiresAt < Date.now()) {
store.delete(makeIdempotencyKey(scope, key));
return null;
}
return entry.value;
}
export function writeIdempotency(scope, key, value, ttlMs) {
store.set(makeIdempotencyKey(scope, key), {
key,
scope,
value,
expiresAt: Date.now() + ttlMs
});
}
export function clearIdempotency(scope, key) {
store.delete(makeIdempotencyKey(scope, key));
}