From ae70df857e525368eb742436458650411c981016 Mon Sep 17 00:00:00 2001 From: Leonardo Camargo Date: Thu, 2 Nov 2023 18:10:16 -0300 Subject: [PATCH] refactor: organize modules into infrastructure --- .../repository/sequelize}/customer-model.ts | 0 .../sequelize}/customer-repository.spec.ts | 6 ++--- .../sequelize}/customer-repository.ts | 8 +++---- .../repository/sequelize}/order-item-model.ts | 2 +- .../repository/sequelize}/order-model.ts | 2 +- .../sequelize}/order-repository.spec.ts | 22 +++++++++---------- .../repository/sequelize}/order-repository.ts | 10 ++++----- .../repository/sequelize}/product-model.ts | 0 .../sequelize}/product-repository.spec.ts | 4 ++-- .../sequelize}/product-repository.ts | 6 ++--- 10 files changed, 30 insertions(+), 30 deletions(-) rename src/infrastructure/{database/sequelize/model => customer/repository/sequelize}/customer-model.ts (100%) rename src/infrastructure/{repository => customer/repository/sequelize}/customer-repository.spec.ts (94%) rename src/infrastructure/{repository => customer/repository/sequelize}/customer-repository.ts (87%) rename src/infrastructure/{database/sequelize/model => order/repository/sequelize}/order-item-model.ts (91%) rename src/infrastructure/{database/sequelize/model => order/repository/sequelize}/order-model.ts (88%) rename src/infrastructure/{repository => order/repository/sequelize}/order-repository.spec.ts (92%) rename src/infrastructure/{repository => order/repository/sequelize}/order-repository.ts (85%) rename src/infrastructure/{database/sequelize/model => product/repository/sequelize}/product-model.ts (100%) rename src/infrastructure/{repository => product/repository/sequelize}/product-repository.spec.ts (94%) rename src/infrastructure/{repository => product/repository/sequelize}/product-repository.ts (79%) diff --git a/src/infrastructure/database/sequelize/model/customer-model.ts b/src/infrastructure/customer/repository/sequelize/customer-model.ts similarity index 100% rename from src/infrastructure/database/sequelize/model/customer-model.ts rename to src/infrastructure/customer/repository/sequelize/customer-model.ts diff --git a/src/infrastructure/repository/customer-repository.spec.ts b/src/infrastructure/customer/repository/sequelize/customer-repository.spec.ts similarity index 94% rename from src/infrastructure/repository/customer-repository.spec.ts rename to src/infrastructure/customer/repository/sequelize/customer-repository.spec.ts index 137368e..30819e2 100644 --- a/src/infrastructure/repository/customer-repository.spec.ts +++ b/src/infrastructure/customer/repository/sequelize/customer-repository.spec.ts @@ -1,8 +1,8 @@ import { Sequelize } from 'sequelize-typescript' -import { CustomerModel } from '../database/sequelize/model/customer-model' import CustomerRepository from './customer-repository' -import { Customer } from '../../domain/customer/entity/customer' -import { Address } from '../../domain/customer/value-object/address' +import { CustomerModel } from './customer-model' +import { Customer } from '../../../../domain/customer/entity/customer' +import { Address } from '../../../../domain/customer/value-object/address' describe('Customer repository test', () => { let sequelize: Sequelize diff --git a/src/infrastructure/repository/customer-repository.ts b/src/infrastructure/customer/repository/sequelize/customer-repository.ts similarity index 87% rename from src/infrastructure/repository/customer-repository.ts rename to src/infrastructure/customer/repository/sequelize/customer-repository.ts index c1ec99e..998f8db 100644 --- a/src/infrastructure/repository/customer-repository.ts +++ b/src/infrastructure/customer/repository/sequelize/customer-repository.ts @@ -1,7 +1,7 @@ -import { Customer } from '../../domain/customer/entity/customer' -import { CustomerRepositoryInterface } from '../../domain/customer/repository/customer-repository.interface' -import { Address } from '../../domain/customer/value-object/address' -import { CustomerModel } from '../database/sequelize/model/customer-model' +import { Customer } from '../../../../domain/customer/entity/customer' +import { CustomerRepositoryInterface } from '../../../../domain/customer/repository/customer-repository.interface' +import { Address } from '../../../../domain/customer/value-object/address' +import { CustomerModel } from './customer-model' export default class CustomerRepository implements CustomerRepositoryInterface { async create (entity: Customer): Promise { diff --git a/src/infrastructure/database/sequelize/model/order-item-model.ts b/src/infrastructure/order/repository/sequelize/order-item-model.ts similarity index 91% rename from src/infrastructure/database/sequelize/model/order-item-model.ts rename to src/infrastructure/order/repository/sequelize/order-item-model.ts index 62cde11..1c91553 100644 --- a/src/infrastructure/database/sequelize/model/order-item-model.ts +++ b/src/infrastructure/order/repository/sequelize/order-item-model.ts @@ -1,6 +1,6 @@ import { BelongsTo, Column, ForeignKey, Model, PrimaryKey, Table } from 'sequelize-typescript' -import { ProductModel } from './product-model' import { OrderModel } from './order-model' +import { ProductModel } from '../../../product/repository/sequelize/product-model' @Table({ tableName: 'order_items', diff --git a/src/infrastructure/database/sequelize/model/order-model.ts b/src/infrastructure/order/repository/sequelize/order-model.ts similarity index 88% rename from src/infrastructure/database/sequelize/model/order-model.ts rename to src/infrastructure/order/repository/sequelize/order-model.ts index 69ee175..b25e276 100644 --- a/src/infrastructure/database/sequelize/model/order-model.ts +++ b/src/infrastructure/order/repository/sequelize/order-model.ts @@ -1,6 +1,6 @@ import { BelongsTo, Column, ForeignKey, HasMany, Model, PrimaryKey, Table } from 'sequelize-typescript' -import { CustomerModel } from './customer-model' import { OrderItemModel } from './order-item-model' +import { CustomerModel } from '../../../customer/repository/sequelize/customer-model' @Table({ tableName: 'orders', diff --git a/src/infrastructure/repository/order-repository.spec.ts b/src/infrastructure/order/repository/sequelize/order-repository.spec.ts similarity index 92% rename from src/infrastructure/repository/order-repository.spec.ts rename to src/infrastructure/order/repository/sequelize/order-repository.spec.ts index 7d029ef..a181a59 100644 --- a/src/infrastructure/repository/order-repository.spec.ts +++ b/src/infrastructure/order/repository/sequelize/order-repository.spec.ts @@ -1,16 +1,16 @@ import { Sequelize } from 'sequelize-typescript' -import { CustomerModel } from '../database/sequelize/model/customer-model' -import CustomerRepository from './customer-repository' -import { Customer } from '../../domain/customer/entity/customer' -import { OrderModel } from '../database/sequelize/model/order-model' -import { OrderItemModel } from '../database/sequelize/model/order-item-model' -import { ProductModel } from '../database/sequelize/model/product-model' -import { ProductRepository } from './product-repository' -import { OrderItem } from '../../domain/checkout/entity/order-item' -import { Order } from '../../domain/checkout/entity/order' import OrderRepository from './order-repository' -import { Address } from '../../domain/customer/value-object/address' -import { Product } from '../../domain/product/entity/product' +import { Customer } from '../../../../domain/customer/entity/customer' +import { Address } from '../../../../domain/customer/value-object/address' +import { Product } from '../../../../domain/product/entity/product' +import { CustomerModel } from '../../../customer/repository/sequelize/customer-model' +import { OrderModel } from './order-model' +import { OrderItemModel } from './order-item-model' +import { ProductRepository } from '../../../product/repository/sequelize/product-repository' +import { OrderItem } from '../../../../domain/checkout/entity/order-item' +import { Order } from '../../../../domain/checkout/entity/order' +import CustomerRepository from '../../../customer/repository/sequelize/customer-repository' +import { ProductModel } from '../../../product/repository/sequelize/product-model' const makeCustomer = (id: string, name: string): Customer => { const customer = new Customer(id, name) diff --git a/src/infrastructure/repository/order-repository.ts b/src/infrastructure/order/repository/sequelize/order-repository.ts similarity index 85% rename from src/infrastructure/repository/order-repository.ts rename to src/infrastructure/order/repository/sequelize/order-repository.ts index 8e39bd9..71e053a 100644 --- a/src/infrastructure/repository/order-repository.ts +++ b/src/infrastructure/order/repository/sequelize/order-repository.ts @@ -1,8 +1,8 @@ -import { Order } from '../../domain/checkout/entity/order' -import { OrderItem } from '../../domain/checkout/entity/order-item' -import { OrderRepositoryInterface } from '../../domain/checkout/repository/order-repository.interface' -import { OrderItemModel } from '../database/sequelize/model/order-item-model' -import { OrderModel } from '../database/sequelize/model/order-model' +import { Order } from '../../../../domain/checkout/entity/order' +import { OrderItem } from '../../../../domain/checkout/entity/order-item' +import { OrderRepositoryInterface } from '../../../../domain/checkout/repository/order-repository.interface' +import { OrderItemModel } from './order-item-model' +import { OrderModel } from './order-model' export default class OrderRepository implements OrderRepositoryInterface { async create (entity: Order): Promise { diff --git a/src/infrastructure/database/sequelize/model/product-model.ts b/src/infrastructure/product/repository/sequelize/product-model.ts similarity index 100% rename from src/infrastructure/database/sequelize/model/product-model.ts rename to src/infrastructure/product/repository/sequelize/product-model.ts diff --git a/src/infrastructure/repository/product-repository.spec.ts b/src/infrastructure/product/repository/sequelize/product-repository.spec.ts similarity index 94% rename from src/infrastructure/repository/product-repository.spec.ts rename to src/infrastructure/product/repository/sequelize/product-repository.spec.ts index bbfa8e5..106b44a 100644 --- a/src/infrastructure/repository/product-repository.spec.ts +++ b/src/infrastructure/product/repository/sequelize/product-repository.spec.ts @@ -1,7 +1,7 @@ import { Sequelize } from 'sequelize-typescript' -import { ProductModel } from '../database/sequelize/model/product-model' import { ProductRepository } from './product-repository' -import { Product } from '../../domain/product/entity/product' +import { ProductModel } from './product-model' +import { Product } from '../../../../domain/product/entity/product' describe('Product repository test', () => { let sequelize: Sequelize diff --git a/src/infrastructure/repository/product-repository.ts b/src/infrastructure/product/repository/sequelize/product-repository.ts similarity index 79% rename from src/infrastructure/repository/product-repository.ts rename to src/infrastructure/product/repository/sequelize/product-repository.ts index 4a2bb1c..e5d9f95 100644 --- a/src/infrastructure/repository/product-repository.ts +++ b/src/infrastructure/product/repository/sequelize/product-repository.ts @@ -1,6 +1,6 @@ -import { Product } from '../../domain/product/entity/product' -import { ProductRepositoryInterface } from '../../domain/product/repository/product-repository.interface' -import { ProductModel } from '../database/sequelize/model/product-model' +import { Product } from '../../../../domain/product/entity/product' +import { ProductRepositoryInterface } from '../../../../domain/product/repository/product-repository.interface' +import { ProductModel } from './product-model' export class ProductRepository implements ProductRepositoryInterface { async create (entity: Product): Promise {