Initial commit

This commit is contained in:
2026-04-05 15:28:04 +02:00
commit 0435b3d07d
43 changed files with 4394 additions and 0 deletions

29
shared/idempotency.js Normal file
View File

@@ -0,0 +1,29 @@
const path = require('path');
const { createHash } = require('crypto');
const { idempotencyDir } = require('./paths');
const { readJsonIfExists, writeJson } = require('./fs');
function recordPath(scope, key) {
const hash = createHash('sha256').update(`${scope}:${key}`).digest('hex');
return path.join(idempotencyDir, scope, `${hash}.json`);
}
async function getIdempotencyRecord(scope, key) {
return readJsonIfExists(recordPath(scope, key));
}
async function saveIdempotencyRecord(scope, key, value) {
await writeJson(recordPath(scope, key), {
schema_version: 'v1',
scope,
key,
value,
created_at: new Date().toISOString(),
});
}
module.exports = {
getIdempotencyRecord,
saveIdempotencyRecord,
};