UNPKG

@mrhsp/auth-backend

Version:

Gate Keeper Backend Authentication Package

27 lines (26 loc) 732 B
export class InMemoryAdapter { constructor() { this.accounts = new Map(); } async getAccount(id) { return this.accounts.get(id) || null; } async addAccount(account) { if (this.accounts.has(account.id)) { throw new Error("Account already exists"); } this.accounts.set(account.id, account); } async updateAccount(account) { if (!this.accounts.has(account.id)) { throw new Error("Account not found"); } this.accounts.set(account.id, account); } async deleteAccount(id) { if (!this.accounts.has(id)) { throw new Error("Account not found"); } this.accounts.delete(id); } }