File size: 906 Bytes
2c16c8c
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
26
27
28
29
30
import { AuthRepositorySupabase } from '@/infra/supabase/repository/auth.repository';
import { AuthService } from './auth.service';
import { AuthController } from './auth.controller';

export class AuthFactory {
  private static repository: AuthRepositorySupabase;
  private static service: AuthService;
  private static controller: AuthController;

  static getRepository() {
    if (!AuthFactory.repository) {
      AuthFactory.repository = new AuthRepositorySupabase();
    }
    return AuthFactory.repository;
  }

  static getService() {
    if (!AuthFactory.service) {
      AuthFactory.service = new AuthService(AuthFactory.getRepository());
    }
    return AuthFactory.service;
  }

  static getController() {
    if (!AuthFactory.controller) {
      AuthFactory.controller = new AuthController(AuthFactory.getService());
    }
    return AuthFactory.controller;
  }
}