import {
  IRepositoryManager,
  RepositoryManager,
} from "@/contexts/common/domain";
import {
  ISequelizeAdapter,
  createSequelizeAdapter,
} from "@/contexts/common/infrastructure/sequelize";

export interface IAuthContext {
  adapter: ISequelizeAdapter;
  repositoryManager: IRepositoryManager;
  //services: IApplicationService;
}

export class AuthContext {
  private static instance: AuthContext | null = null;

  public static getInstance(): IAuthContext {
    if (!AuthContext.instance) {
      AuthContext.instance = new AuthContext({
        adapter: createSequelizeAdapter(),
        repositoryManager: RepositoryManager.getInstance(),
      });
    }

    return AuthContext.instance.context;
  }

  private context: IAuthContext;

  private constructor(context: IAuthContext) {
    this.context = context;
  }
}
