@hookflo/tern
Version:
A robust, scalable webhook verification framework supporting multiple platforms and signature algorithms
40 lines (39 loc) • 1.16 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.InMemoryStorageAdapter = void 0;
const registry_1 = require("../templates/registry");
class InMemoryStorageAdapter {
constructor() {
this.schemas = new Map();
}
async saveSchema(schema) {
this.schemas.set(schema.id, schema);
}
async getSchema(id) {
return this.schemas.get(id) ?? null;
}
async updateSchema(id, updates) {
const existing = this.schemas.get(id);
if (!existing)
return;
const updated = {
...existing,
...updates,
updatedAt: new Date(),
};
this.schemas.set(id, updated);
}
async deleteSchema(id) {
this.schemas.delete(id);
}
async listSchemas(userId) {
return Array.from(this.schemas.values()).filter((s) => s.userId === userId);
}
async getBaseTemplate(id) {
return registry_1.templateRegistry.getById(id) ?? null;
}
async listBaseTemplates() {
return registry_1.templateRegistry.listAll();
}
}
exports.InMemoryStorageAdapter = InMemoryStorageAdapter;