All files / app/service requestService.ts

100% Statements 25/25
100% Branches 8/8
100% Functions 8/8
100% Lines 25/25

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 24 25 265x 5x 5x 1x 1x 1x 4x 4x 1x 1x 3x 3x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x  
import { IStorage } from '../types/IStorage.js';
 
export class RequestService {
  private readonly storageService;
 
  constructor(storageService: IStorage) {
    this.storageService = storageService;
  }
 
  private getStorageId(ticket: number) {
    return `fib_request_${ticket}`;
  }
 
  addRequest(ticket: number, inputNumber: number) {
    return this.storageService.set(this.getStorageId(ticket), JSON.stringify({ inputNumber }));
  }
 
  getRequest(ticket: number) {
    return this.storageService.get(this.getStorageId(ticket));
  }
 
  updateRequestWithData<T>(ticket: number, data: T) {
    return this.storageService.set(this.getStorageId(ticket), JSON.stringify(data));
  }
}