diff --git a/src/app/api/organizations/[id]/ledgers/[ledgerId]/portfolios/[portfolioId]/accounts/[accountId]/route.ts b/src/app/api/organizations/[id]/ledgers/[ledgerId]/portfolios/[portfolioId]/accounts/[accountId]/route.ts index a345b1e6..78d179c6 100644 --- a/src/app/api/organizations/[id]/ledgers/[ledgerId]/portfolios/[portfolioId]/accounts/[accountId]/route.ts +++ b/src/app/api/organizations/[id]/ledgers/[ledgerId]/portfolios/[portfolioId]/accounts/[accountId]/route.ts @@ -1,23 +1,27 @@ +import { container } from '@/core/infrastructure/container-registry/container-registry' import { apiErrorHandler } from '@/app/api/utils/api-error-handler' -import { DeleteAccount } from '@/core/application/use-cases/accounts/delete-account-use-case' -import { FetchAccountById } from '@/core/application/use-cases/accounts/fetch-account-by-id-use-case' -import { UpdateAccount } from '@/core/application/use-cases/accounts/update-account-use-case' import { - container, - Registry -} from '@/core/infrastructure/container-registry/container-registry' + DeleteAccount, + DeleteAccountUseCase +} from '@/core/application/use-cases/accounts/delete-account-use-case' +import { + FetchAccountById, + FetchAccountByIdUseCase +} from '@/core/application/use-cases/accounts/fetch-account-by-id-use-case' +import { + UpdateAccount, + UpdateAccountUseCase +} from '@/core/application/use-cases/accounts/update-account-use-case' import { NextResponse } from 'next/server' -const updateAccountUseCase: UpdateAccount = container.get( - Registry.UpdateAccountUseCase -) +const updateAccountUseCase: UpdateAccount = + container.get(UpdateAccountUseCase) -const deleteAccountUseCase: DeleteAccount = container.get( - Registry.DeleteAccountUseCase -) +const deleteAccountUseCase: DeleteAccount = + container.get(DeleteAccountUseCase) const getAccountByIdUseCase: FetchAccountById = container.get( - Registry.FetchAccountByIdUseCase + FetchAccountByIdUseCase ) export async function GET( diff --git a/src/app/api/organizations/[id]/ledgers/[ledgerId]/portfolios/[portfolioId]/accounts/route.ts b/src/app/api/organizations/[id]/ledgers/[ledgerId]/portfolios/[portfolioId]/accounts/route.ts index c2c33022..e9f38cfc 100644 --- a/src/app/api/organizations/[id]/ledgers/[ledgerId]/portfolios/[portfolioId]/accounts/route.ts +++ b/src/app/api/organizations/[id]/ledgers/[ledgerId]/portfolios/[portfolioId]/accounts/route.ts @@ -1,21 +1,22 @@ +import { container } from '@/core/infrastructure/container-registry/container-registry' import { apiErrorHandler } from '@/app/api/utils/api-error-handler' -import { CreateAccount } from '@/core/application/use-cases/accounts/create-account-use-case' -import { FetchAllAccounts } from '@/core/application/use-cases/accounts/fetch-all-account-use-case' -// Update import statements - import { - container, - Registry -} from '@/core/infrastructure/container-registry/container-registry' + CreateAccount, + CreateAccountUseCase +} from '@/core/application/use-cases/accounts/create-account-use-case' +import { + FetchAllAccounts, + FetchAllAccountsUseCase +} from '@/core/application/use-cases/accounts/fetch-all-account-use-case' + import { NextResponse } from 'next/server' // Update use case references -const createAccountUseCase: CreateAccount = container.get( - Registry.CreateAccountUseCase -) +const createAccountUseCase: CreateAccount = + container.get(CreateAccountUseCase) const fetchAllAccountsUseCase: FetchAllAccounts = - container.get(Registry.FetchAllAccountsUseCase) + container.get(FetchAllAccountsUseCase) export async function GET( request: Request, diff --git a/src/core/application/use-cases/accounts/create-account-use-case.ts b/src/core/application/use-cases/accounts/create-account-use-case.ts index ff8d6c47..c1578f00 100644 --- a/src/core/application/use-cases/accounts/create-account-use-case.ts +++ b/src/core/application/use-cases/accounts/create-account-use-case.ts @@ -2,6 +2,7 @@ import { CreateAccountsRepository } from '@/core/domain/repositories/accounts/cr import { CreateAccountDto, AccountResponseDto } from '../../dto/account-dto' import { AccountEntity } from '@/core/domain/entities/account-entity' import { AccountMapper } from '../../mappers/account-mapper' +import { inject, injectable } from 'inversify' export interface CreateAccount { execute: ( @@ -12,8 +13,10 @@ export interface CreateAccount { ) => Promise } +@injectable() export class CreateAccountUseCase implements CreateAccount { constructor( + @inject(CreateAccountsRepository) private readonly createAccountRepository: CreateAccountsRepository ) {} diff --git a/src/core/application/use-cases/accounts/delete-account-use-case.ts b/src/core/application/use-cases/accounts/delete-account-use-case.ts index 9b95a649..a5bbd7a4 100644 --- a/src/core/application/use-cases/accounts/delete-account-use-case.ts +++ b/src/core/application/use-cases/accounts/delete-account-use-case.ts @@ -1,4 +1,5 @@ import { DeleteAccountsRepository } from '@/core/domain/repositories/accounts/delete-accounts-repository' +import { inject, injectable } from 'inversify' export interface DeleteAccount { execute: ( @@ -9,8 +10,10 @@ export interface DeleteAccount { ) => Promise } +@injectable() export class DeleteAccountUseCase implements DeleteAccount { constructor( + @inject(DeleteAccountsRepository) private readonly deleteAccountRepository: DeleteAccountsRepository ) {} diff --git a/src/core/application/use-cases/accounts/fetch-account-by-id-use-case.ts b/src/core/application/use-cases/accounts/fetch-account-by-id-use-case.ts index 3e1e50d2..73f14ea1 100644 --- a/src/core/application/use-cases/accounts/fetch-account-by-id-use-case.ts +++ b/src/core/application/use-cases/accounts/fetch-account-by-id-use-case.ts @@ -1,6 +1,7 @@ import { FetchAccountByIdRepository } from '@/core/domain/repositories/accounts/fetch-account-by-id-repository' import { AccountResponseDto } from '../../dto/account-dto' import { AccountMapper } from '../../mappers/account-mapper' +import { inject, injectable } from 'inversify' export interface FetchAccountById { execute: ( @@ -11,8 +12,10 @@ export interface FetchAccountById { ) => Promise } +@injectable() export class FetchAccountByIdUseCase implements FetchAccountById { constructor( + @inject(FetchAccountByIdRepository) private readonly fetchAccountByIdRepository: FetchAccountByIdRepository ) {} diff --git a/src/core/application/use-cases/accounts/fetch-all-account-use-case.ts b/src/core/application/use-cases/accounts/fetch-all-account-use-case.ts index 3836bc81..6c9dce29 100644 --- a/src/core/application/use-cases/accounts/fetch-all-account-use-case.ts +++ b/src/core/application/use-cases/accounts/fetch-all-account-use-case.ts @@ -4,6 +4,7 @@ import { AccountMapper } from '../../mappers/account-mapper' import { AccountEntity } from '@/core/domain/entities/account-entity' import { AccountResponseDto } from '../../dto/account-dto' import { FetchAllAccountsRepository } from '@/core/domain/repositories/accounts/fetch-all-accounts-repository' +import { inject, injectable } from 'inversify' export interface FetchAllAccounts { execute: ( @@ -15,8 +16,10 @@ export interface FetchAllAccounts { ) => Promise> } +@injectable() export class FetchAllAccountsUseCase implements FetchAllAccounts { constructor( + @inject(FetchAllAccountsRepository) private readonly fetchAllAccountsRepository: FetchAllAccountsRepository ) {} diff --git a/src/core/application/use-cases/accounts/update-account-use-case.ts b/src/core/application/use-cases/accounts/update-account-use-case.ts index bfb2681e..fb7163de 100644 --- a/src/core/application/use-cases/accounts/update-account-use-case.ts +++ b/src/core/application/use-cases/accounts/update-account-use-case.ts @@ -2,6 +2,7 @@ import { UpdateAccountsRepository } from '@/core/domain/repositories/accounts/up import { AccountResponseDto, UpdateAccountDto } from '../../dto/account-dto' import { AccountMapper } from '../../mappers/account-mapper' import { AccountEntity } from '@/core/domain/entities/account-entity' +import { inject, injectable } from 'inversify' export interface UpdateAccount { execute: ( @@ -13,8 +14,10 @@ export interface UpdateAccount { ) => Promise } +@injectable() export class UpdateAccountUseCase implements UpdateAccount { constructor( + @inject(UpdateAccountsRepository) private readonly updateAccountRepository: UpdateAccountsRepository ) {} diff --git a/src/core/domain/repositories/accounts/create-accounts-repository.ts b/src/core/domain/repositories/accounts/create-accounts-repository.ts index 66ad7bd0..10be10cb 100644 --- a/src/core/domain/repositories/accounts/create-accounts-repository.ts +++ b/src/core/domain/repositories/accounts/create-accounts-repository.ts @@ -1,8 +1,7 @@ -import { PortfolioEntity } from '@/core/domain/entities/portfolios-entity' import { AccountEntity } from '../../entities/account-entity' -export interface CreateAccountsRepository { - create: ( +export abstract class CreateAccountsRepository { + abstract create: ( organizationId: string, ledgerId: string, portfolioId: string, diff --git a/src/core/domain/repositories/accounts/delete-accounts-repository.ts b/src/core/domain/repositories/accounts/delete-accounts-repository.ts index 9b5f8d84..d9cd82af 100644 --- a/src/core/domain/repositories/accounts/delete-accounts-repository.ts +++ b/src/core/domain/repositories/accounts/delete-accounts-repository.ts @@ -1,5 +1,5 @@ -export interface DeleteAccountsRepository { - delete: ( +export abstract class DeleteAccountsRepository { + abstract delete: ( organizationId: string, ledgerId: string, portfolioId: string, diff --git a/src/core/domain/repositories/accounts/fetch-account-by-id-repository.ts b/src/core/domain/repositories/accounts/fetch-account-by-id-repository.ts index 28b412d6..0faf0a7a 100644 --- a/src/core/domain/repositories/accounts/fetch-account-by-id-repository.ts +++ b/src/core/domain/repositories/accounts/fetch-account-by-id-repository.ts @@ -1,7 +1,7 @@ import { AccountEntity } from '../../entities/account-entity' -export interface FetchAccountByIdRepository { - fetchById: ( +export abstract class FetchAccountByIdRepository { + abstract fetchById: ( organizationId: string, ledgerId: string, portfolioId: string, diff --git a/src/core/domain/repositories/accounts/fetch-all-accounts-repository.ts b/src/core/domain/repositories/accounts/fetch-all-accounts-repository.ts index e0a8e6b6..d2d35b41 100644 --- a/src/core/domain/repositories/accounts/fetch-all-accounts-repository.ts +++ b/src/core/domain/repositories/accounts/fetch-all-accounts-repository.ts @@ -1,8 +1,8 @@ import { AccountEntity } from '../../entities/account-entity' import { PaginationEntity } from '../../entities/pagination-entity' -export interface FetchAllAccountsRepository { - fetchAll: ( +export abstract class FetchAllAccountsRepository { + abstract fetchAll: ( organizationId: string, ledgerId: string, portfolioId: string, diff --git a/src/core/domain/repositories/accounts/update-accounts-repository.ts b/src/core/domain/repositories/accounts/update-accounts-repository.ts index ee7637ae..1dd03d56 100644 --- a/src/core/domain/repositories/accounts/update-accounts-repository.ts +++ b/src/core/domain/repositories/accounts/update-accounts-repository.ts @@ -1,7 +1,7 @@ import { AccountEntity } from '../../entities/account-entity' -export interface UpdateAccountsRepository { - update: ( +export abstract class UpdateAccountsRepository { + abstract update: ( organizationId: string, ledgerId: string, portfolioId: string, diff --git a/src/core/infrastructure/container-registry/account-module.ts b/src/core/infrastructure/container-registry/account-module.ts deleted file mode 100644 index a2b01e69..00000000 --- a/src/core/infrastructure/container-registry/account-module.ts +++ /dev/null @@ -1,110 +0,0 @@ -import { ContainerModule, interfaces } from 'inversify' -import { FetchAllAccountsRepository } from '@/core/domain/repositories/accounts/fetch-all-accounts-repository' -import { MidazFetchAllAccountsRepository } from '../midaz/accounts/midaz-fetch-all-accounts-repository' -import { - FetchAllAccounts, - FetchAllAccountsUseCase -} from '@/core/application/use-cases/accounts/fetch-all-account-use-case' -import { CreateAccountsRepository } from '@/core/domain/repositories/accounts/create-accounts-repository' -import { - CreateAccount, - CreateAccountUseCase -} from '@/core/application/use-cases/accounts/create-account-use-case' -import { MidazCreateAccountRepository } from '../midaz/accounts/midaz-create-accounts-repository' -import { FetchAccountByIdRepository } from '@/core/domain/repositories/accounts/fetch-account-by-id-repository' -import { MidazFetchAccountByIdRepository } from '../midaz/accounts/midaz-fetch-account-by-id-repository' -import { - FetchAccountById, - FetchAccountByIdUseCase -} from '@/core/application/use-cases/accounts/fetch-account-by-id-use-case' -import { UpdateAccountsRepository } from '@/core/domain/repositories/accounts/update-accounts-repository' -import { MidazUpdateAccountsRepository } from '../midaz/accounts/midaz-update-accounts-repository' -import { - UpdateAccount, - UpdateAccountUseCase -} from '@/core/application/use-cases/accounts/update-account-use-case' -import { DeleteAccountsRepository } from '@/core/domain/repositories/accounts/delete-accounts-repository' -import { MidazDeleteAccountsRepository } from '../midaz/accounts/midaz-delete-accounts-repository' -import { - DeleteAccount, - DeleteAccountUseCase -} from '@/core/application/use-cases/accounts/delete-account-use-case' - -export const AccountRegistry = { - FetchAllAccountsUseCase: Symbol.for('FetchAllAccountsUseCase'), - FetchAllAccountsRepository: Symbol.for('FetchAllAccountsRepository'), - CreateAccountsRepository: Symbol.for('CreateAccountsRepository'), - CreateAccountUseCase: Symbol.for('CreateAccountUseCase'), - CreateAccountSymbolRepository: Symbol.for('CreateAccountSymbolRepository'), - FetchAccountByIdRepository: Symbol.for('FetchAccountByIdRepository'), - FetchAccountByIdUseCase: Symbol.for('FetchAccountByIdUseCase'), - UpdateAccountRepository: Symbol.for('UpdateAccountRepository'), - UpdateAccountUseCase: Symbol.for('UpdateAccountUseCase'), - DeleteAccountRepository: Symbol.for('DeleteAccountRepository'), - DeleteAccountUseCase: Symbol.for('DeleteAccountUseCase') -} - -export const AccountModule = new ContainerModule((bind: interfaces.Bind) => { - bind( - AccountRegistry.FetchAllAccountsRepository - ).toConstantValue(new MidazFetchAllAccountsRepository()) - - bind( - AccountRegistry.FetchAllAccountsUseCase - ).toDynamicValue((context) => { - return new FetchAllAccountsUseCase( - context.container.get(AccountRegistry.FetchAllAccountsRepository) - ) - }) - - bind( - AccountRegistry.CreateAccountsRepository - ).toConstantValue(new MidazCreateAccountRepository()) - - bind(AccountRegistry.CreateAccountUseCase).toDynamicValue( - (context) => { - return new CreateAccountUseCase( - context.container.get(AccountRegistry.CreateAccountsRepository) - ) - } - ) - - // Fetch Account By Id - bind( - AccountRegistry.FetchAccountByIdRepository - ).toConstantValue(new MidazFetchAccountByIdRepository()) - - bind( - AccountRegistry.FetchAccountByIdUseCase - ).toDynamicValue((context) => { - return new FetchAccountByIdUseCase( - context.container.get(AccountRegistry.FetchAccountByIdRepository) - ) - }) - - // Update Account - bind( - AccountRegistry.UpdateAccountRepository - ).toConstantValue(new MidazUpdateAccountsRepository()) - - bind(AccountRegistry.UpdateAccountUseCase).toDynamicValue( - (context) => { - return new UpdateAccountUseCase( - context.container.get(AccountRegistry.UpdateAccountRepository) - ) - } - ) - - // Delete Account - bind( - AccountRegistry.DeleteAccountRepository - ).toConstantValue(new MidazDeleteAccountsRepository()) - - bind(AccountRegistry.DeleteAccountUseCase).toDynamicValue( - (context) => { - return new DeleteAccountUseCase( - context.container.get(AccountRegistry.DeleteAccountRepository) - ) - } - ) -}) diff --git a/src/core/infrastructure/container-registry/container-registry.ts b/src/core/infrastructure/container-registry/container-registry.ts index 7c9fed1f..f7054006 100644 --- a/src/core/infrastructure/container-registry/container-registry.ts +++ b/src/core/infrastructure/container-registry/container-registry.ts @@ -5,7 +5,6 @@ import { } from '@/core/application/use-cases/portfolios-accounts/fetch-portfolios-accounts-use-case' import { AuthModule, AuthRegistry } from './auth-module' -import { AccountModule, AccountRegistry } from './account-module' import { AssetModule, AssetRegistry } from './asset-module' import { ProductRegistry, ProductModule } from './product-module' @@ -23,10 +22,10 @@ import { MidazFetchAllAssetsRepository } from '../midaz/assets/midaz-fetch-all-a import { MidazFetchAllPortfoliosRepository } from '../midaz/portfolios/midaz-fetch-all-portfolio-repository' import { MidazFetchAllAccountsRepository } from '../midaz/accounts/midaz-fetch-all-accounts-repository' import { PortfolioUseCaseModule } from './use-cases/portfolios-module' +import { AccountUseCaseModule } from './use-cases/account-module' export const Registry = { ...AuthRegistry, - ...AccountRegistry, ...AssetRegistry, ...ProductRegistry, @@ -43,9 +42,9 @@ container.load(MidazModule) container.load(OrganizationUseCaseModule) container.load(LedgerUseCaseModule) container.load(PortfolioUseCaseModule) +container.load(AccountUseCaseModule) container.container.load(AuthModule) -container.container.load(AccountModule) container.container.load(AssetModule) container.container.load(ProductModule) diff --git a/src/core/infrastructure/container-registry/use-cases/account-module.ts b/src/core/infrastructure/container-registry/use-cases/account-module.ts new file mode 100644 index 00000000..c1591ff7 --- /dev/null +++ b/src/core/infrastructure/container-registry/use-cases/account-module.ts @@ -0,0 +1,32 @@ +import { Container, ContainerModule } from '../../utils/di/container' + +import { + FetchAllAccounts, + FetchAllAccountsUseCase +} from '@/core/application/use-cases/accounts/fetch-all-account-use-case' +import { + CreateAccount, + CreateAccountUseCase +} from '@/core/application/use-cases/accounts/create-account-use-case' +import { + FetchAccountById, + FetchAccountByIdUseCase +} from '@/core/application/use-cases/accounts/fetch-account-by-id-use-case' +import { + UpdateAccount, + UpdateAccountUseCase +} from '@/core/application/use-cases/accounts/update-account-use-case' +import { + DeleteAccount, + DeleteAccountUseCase +} from '@/core/application/use-cases/accounts/delete-account-use-case' + +export const AccountUseCaseModule = new ContainerModule( + (container: Container) => { + container.bind(FetchAllAccountsUseCase).toSelf() + container.bind(CreateAccountUseCase).toSelf() + container.bind(FetchAccountByIdUseCase).toSelf() + container.bind(UpdateAccountUseCase).toSelf() + container.bind(DeleteAccountUseCase).toSelf() + } +) diff --git a/src/core/infrastructure/midaz/accounts/midaz-create-accounts-repository.ts b/src/core/infrastructure/midaz/accounts/midaz-create-accounts-repository.ts index a0ed151a..fd6f1f6a 100644 --- a/src/core/infrastructure/midaz/accounts/midaz-create-accounts-repository.ts +++ b/src/core/infrastructure/midaz/accounts/midaz-create-accounts-repository.ts @@ -1,8 +1,9 @@ -import { PortfolioEntity } from '@/core/domain/entities/portfolios-entity' import { HTTP_METHODS, httpMidazAuthFetch } from '../../utils/http-fetch-utils' import { AccountEntity } from '@/core/domain/entities/account-entity' import { CreateAccountsRepository } from '@/core/domain/repositories/accounts/create-accounts-repository' +import { injectable } from 'inversify' +@injectable() export class MidazCreateAccountRepository implements CreateAccountsRepository { private baseUrl: string = process.env.MIDAZ_BASE_PATH as string async create( diff --git a/src/core/infrastructure/midaz/accounts/midaz-delete-accounts-repository.ts b/src/core/infrastructure/midaz/accounts/midaz-delete-accounts-repository.ts index 17fa3dd8..20cc5026 100644 --- a/src/core/infrastructure/midaz/accounts/midaz-delete-accounts-repository.ts +++ b/src/core/infrastructure/midaz/accounts/midaz-delete-accounts-repository.ts @@ -1,6 +1,8 @@ +import { injectable } from 'inversify' import { HTTP_METHODS, httpMidazAuthFetch } from '../../utils/http-fetch-utils' import { DeleteAccountsRepository } from '@/core/domain/repositories/accounts/delete-accounts-repository' +@injectable() export class MidazDeleteAccountsRepository implements DeleteAccountsRepository { private baseUrl: string = process.env.MIDAZ_BASE_PATH as string diff --git a/src/core/infrastructure/midaz/accounts/midaz-fetch-account-by-id-repository.ts b/src/core/infrastructure/midaz/accounts/midaz-fetch-account-by-id-repository.ts index dca9ce88..45a991c5 100644 --- a/src/core/infrastructure/midaz/accounts/midaz-fetch-account-by-id-repository.ts +++ b/src/core/infrastructure/midaz/accounts/midaz-fetch-account-by-id-repository.ts @@ -1,7 +1,9 @@ import { AccountEntity } from '@/core/domain/entities/account-entity' import { FetchAccountByIdRepository } from '@/core/domain/repositories/accounts/fetch-account-by-id-repository' import { HTTP_METHODS, httpMidazAuthFetch } from '../../utils/http-fetch-utils' +import { injectable } from 'inversify' +@injectable() export class MidazFetchAccountByIdRepository implements FetchAccountByIdRepository { diff --git a/src/core/infrastructure/midaz/accounts/midaz-fetch-all-accounts-repository.ts b/src/core/infrastructure/midaz/accounts/midaz-fetch-all-accounts-repository.ts index af350302..18c44c39 100644 --- a/src/core/infrastructure/midaz/accounts/midaz-fetch-all-accounts-repository.ts +++ b/src/core/infrastructure/midaz/accounts/midaz-fetch-all-accounts-repository.ts @@ -2,7 +2,9 @@ import { PaginationEntity } from '@/core/domain/entities/pagination-entity' import { HTTP_METHODS, httpMidazAuthFetch } from '../../utils/http-fetch-utils' import { FetchAllAccountsRepository } from '@/core/domain/repositories/accounts/fetch-all-accounts-repository' import { AccountEntity } from '@/core/domain/entities/account-entity' +import { injectable } from 'inversify' +@injectable() export class MidazFetchAllAccountsRepository implements FetchAllAccountsRepository { diff --git a/src/core/infrastructure/midaz/accounts/midaz-update-accounts-repository.ts b/src/core/infrastructure/midaz/accounts/midaz-update-accounts-repository.ts index bdc00c5d..df049e22 100644 --- a/src/core/infrastructure/midaz/accounts/midaz-update-accounts-repository.ts +++ b/src/core/infrastructure/midaz/accounts/midaz-update-accounts-repository.ts @@ -1,7 +1,9 @@ import { httpMidazAuthFetch, HTTP_METHODS } from '../../utils/http-fetch-utils' import { UpdateAccountsRepository } from '@/core/domain/repositories/accounts/update-accounts-repository' import { AccountEntity } from '@/core/domain/entities/account-entity' +import { injectable } from 'inversify' +@injectable() export class MidazUpdateAccountsRepository implements UpdateAccountsRepository { private baseUrl: string = process.env.MIDAZ_BASE_PATH as string diff --git a/src/core/infrastructure/midaz/module/account-module.ts b/src/core/infrastructure/midaz/module/account-module.ts new file mode 100644 index 00000000..079d9826 --- /dev/null +++ b/src/core/infrastructure/midaz/module/account-module.ts @@ -0,0 +1,37 @@ +import { Container, ContainerModule } from '../../utils/di/container' + +import { FetchAllAccountsRepository } from '@/core/domain/repositories/accounts/fetch-all-accounts-repository' +import { CreateAccountsRepository } from '@/core/domain/repositories/accounts/create-accounts-repository' +import { FetchAccountByIdRepository } from '@/core/domain/repositories/accounts/fetch-account-by-id-repository' +import { UpdateAccountsRepository } from '@/core/domain/repositories/accounts/update-accounts-repository' +import { DeleteAccountsRepository } from '@/core/domain/repositories/accounts/delete-accounts-repository' + +import { MidazFetchAllAccountsRepository } from '../accounts/midaz-fetch-all-accounts-repository' +import { MidazCreateAccountRepository } from '../accounts/midaz-create-accounts-repository' +import { MidazFetchAccountByIdRepository } from '../accounts/midaz-fetch-account-by-id-repository' +import { MidazUpdateAccountsRepository } from '../accounts/midaz-update-accounts-repository' +import { MidazDeleteAccountsRepository } from '../accounts/midaz-delete-accounts-repository' + +export const MidazAccountModule = new ContainerModule( + (container: Container) => { + container + .bind(FetchAllAccountsRepository) + .to(MidazFetchAllAccountsRepository) + + container + .bind(CreateAccountsRepository) + .to(MidazCreateAccountRepository) + + container + .bind(FetchAccountByIdRepository) + .to(MidazFetchAccountByIdRepository) + + container + .bind(UpdateAccountsRepository) + .to(MidazUpdateAccountsRepository) + + container + .bind(DeleteAccountsRepository) + .to(MidazDeleteAccountsRepository) + } +) diff --git a/src/core/infrastructure/midaz/module/midaz-module.ts b/src/core/infrastructure/midaz/module/midaz-module.ts index 6fe154ba..1f6cfc82 100644 --- a/src/core/infrastructure/midaz/module/midaz-module.ts +++ b/src/core/infrastructure/midaz/module/midaz-module.ts @@ -1,4 +1,5 @@ import { Container, ContainerModule } from '../../utils/di/container' +import { MidazAccountModule } from './account-module' import { MidazLedgerModule } from './ledger-module' import { MidazOrganizationModule } from './organization-module' import { MidazPortfolioModule } from './portfolio-module' @@ -7,4 +8,5 @@ export const MidazModule = new ContainerModule((container: Container) => { container.load(MidazOrganizationModule) container.load(MidazLedgerModule) container.load(MidazPortfolioModule) + container.load(MidazAccountModule) })