All files / src/modules/domain/auth/user-session/services user-session.service.ts

0% Statements 0/8
100% Branches 0/0
0% Functions 0/2
0% Lines 0/6

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                                     
import { Injectable } from '@nestjs/common';
import { UserSessionRepository } from 'src/modules/common/database/mongo/auth/repositories/user-session.repository';
import { IWithMongoId } from 'src/modules/common/database/mongo/shared/mongo.interface';
import { TPartialBy } from 'src/shared/interface';
import { IUserSession } from '../shared/user-session.interface';
 
@Injectable()
export class UserSessionService {
  constructor(private readonly userSessionRepository: UserSessionRepository) {}
 
  async captureLatestSession(
    input: TPartialBy<IUserSession, 'isDeleted' | 'createdAt' | 'updatedAt'> & IWithMongoId,
  ) {
    await this.userSessionRepository.invalidateAll();
 
    return this.userSessionRepository.create(input);
  }
}