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

export interface IProfileContext {
  adapter: ISequelizeAdapter;
  repositoryManager: IRepositoryManager;
}

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

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

    return ProfileContext.instance.context;
  }

  private context: IProfileContext;

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