1 import { v4 as uuid } from 'uuid';
2 import { ERROR_CODE, NotFoundError } from '../errors';
3 import {Repository} from './base';
5 export type Session = {
10 export class SessionRepository extends Repository<Session> {
15 async create(accountId: string): Promise<Session>{
25 await this.Insert(data);
30 async validate(accountId: string, token: string): Promise<Session> {
36 const session = await this.FindOne(data);
38 throw new NotFoundError('Session Invalid', ERROR_CODE.INVALID_USER_TOKEN);