Components for Working with Infrastructure Layer(contexts/{context}/infrastructure/)
The sections below present the main package components for working with the infrastructure layer.
Expected folder structure:
infrastructure/
├── http/
│ ├── datasources/ # Data source implementations for specific context (optional, if there's one base)
│ ├── responses/ # Response implementations for specific context (optional, if there's one base)
│ ├── dto/ # Project DTO implementations (optional, only when transformation to domain entity is required)
│ └── repositories/ # Repository implementations
│ ├── UserRepository.ts
│ ├── AuthRepository.ts
│ └── index.ts
├── providers/ # Infrastructure providers
│ ├── DatasourceProvider.ts # Located here in cases when data source is bound to context
│ ├── InfrastructureProvider.ts
│ └── index.ts
└── index.tsFor working with the infrastructure layer, you should:
- Create a base Response (how, in what situations and where it's created is described in the section below).
- Create a data source and pass it a configured httpService and queryBuilder, and also implement a method that returns a Response.
- Create a provider for the data source.
Then repositories and a provider for the infrastructure layer are created.
A detailed description of how to do this with a complete example at the end and a detailed description of each component are provided in the sections below.