All files / src/auth/session/storage memory.ts

100% Statements 22/22
75% Branches 3/4
100% Functions 11/11
100% Lines 22/22

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23  22x 22x 22x 22x   204x   22x 43x 43x 43x 43x       22x 57x 57x 57x      
import {SessionInterface} from '../types';
import {SessionStorage} from '../session_storage';
 
export class MemorySessionStorage implements SessionStorage {
  private sessions: {[id: string]: SessionInterface} = {};
 
  public async storeSession(session: SessionInterface): Promise<boolean> {
    this.sessions[session.id] = session;
    return true;
  }
 
  public async loadSession(id: string): Promise<SessionInterface | undefined> {
    return this.sessions[id] || undefined;
  }
 
  public async deleteSession(id: string): Promise<boolean> {
    if (this.sessions[id]) {
      delete this.sessions[id];
    }
    return true;
  }
}