import { getDatabase } from "@/config";
import { SequelizeTransactionManager } from "@/core/common/infrastructure";
import { AuthService, TabContextService } from "../../domain/services";
import { authenticatedUserMapper, tabContextMapper } from "../mappers";
import { AuthenticatedUserRepository, TabContextRepository } from "../sequelize";
import { PassportAuthProvider } from "./passport-auth-provider";

const database = getDatabase();

const authenticatedUserRepository = new AuthenticatedUserRepository(
  database,
  authenticatedUserMapper
);
const tabContextRepository = new TabContextRepository(database, tabContextMapper);
const transactionManager = new SequelizeTransactionManager(database);
const authService = new AuthService(authenticatedUserRepository, tabContextRepository);
const tabContextService = new TabContextService(tabContextRepository);

const authProvider = new PassportAuthProvider(authService, tabContextService, transactionManager);
export { authProvider };
