이것은 REST API를 구축하기 위해 지속적으로 지속적으로 진행중인 스타터 템플릿입니다.
이 템플릿은 코딩을 시작하고 이미 생각한 프로젝트 구조를 원한다면 매우 간단하고 빠르며 작고 더 큰 프로젝트에서 잘 작동합니다.
app -> App and related files
├─> src -> App source
│ ├─> Web -> Entry point for API - runnable project
│ │ ├─> Controllers -> API endpoints
│ │ ├─> Extensions -> Extension methods
│ │ ├─> Interfaces -> Web project's interfaces
│ │ ├─> Mappers -> Model mappers
│ │ ├─> Middlewares -> Middlewares (e.g. global error handling)
│ │ |─> Models -> Models in and out of API
│ │ ├─> Settings -> Options pattern for App (e.g. connection strings)
│ │ ├─> Validators -> Model validation rules
│ │ ├── Program.cs -> START
│ │ └── Startup.cs -> START
│ ├─> Core -> Holds business logic
│ │ ├─> Dtos -> Data-transfer-object (used for business logic)
│ │ ├─> Entities -> Entity Framework entities for database
│ │ ├─> Interfaces -> Core project's interfaces
│ │ ├─> Mappers -> Dto and Entity mappers
│ │ ├─> Services -> Business logic services
│ └─> Infrastructure -> Data access and external services
│ ├─> Database -> Database access
│ │ ├─> Configurations -> Entity Framework table configurations
│ │ ├─> Migrations -> Entity Framework autogenerated migrations
│ │ ├─> Repositories -> Repository pattern
│ │ ├── AppDbContext.cs -> Base context
│ │ ├── AppSeed.cs -> Database seeding
│ │ └── EfRepository.cs -> Base repository
│ └─> ExternalServices -> Services that access external services (e.g. ext. email service)
└─> tests -> App tests
├── FunctionalTests -> Endpoint tests etc.
│ ├─> Tests -> All tests
│ └─> Utils -> Utility functions (e.g. test database setup)
├── IntegrationTests -> Database tests etc.
│ ├─> Tests -> All tests
│ ├─> Utils -> Utilities functions (e.g. test database setup)
├── UnitTests -> Application logic tests etc.
│ ├─> Tests -> All tests
│ ├─> Utils -> Utility functions
└── Shared -> Model builders and other shared functions for tests
dotnet tool install --global dotnet-ef
dotnet ef database update -c ApplicationDbContext -p . /src/Infrastructure/Infrastructure.csproj -s . /src/Web/Web.csprojMyWebAPITemplate.sln 으로 열립니다F5 누르거나 Debug/Start Debugging dotnet run -p . /src/Web/새 마이그레이션을 만들어야 할 때 (데이터베이스 스키마를 변경할 때)이 명령을 실행하여 엔티티 프레임 워크에 데이터베이스에 필요한 스키마 변경 사항을 처리하도록 지시하십시오.
dotnet ef migrations add NewMigrationNameHere --context ApplicationDbContext -p . /src/Infrastructure/Infrastructure.csproj -s . /src/Web/Web.csproj -o Database /Migrations 이 프로젝트는 단일 모 놀리 식 방식으로 API를 구축 할 때 수행 해야하는 모든 정보 흐름을 처리하는 방법으로 시작되었습니다. 기억해야 할 것들이 너무 많고 선택해야 할 많은 선택이 있습니다. 그러므로 나는이 템플릿을 직접 만들었고 실용적인 모든 관행을 저장 했으며이 템플릿이 다른 사람이 한두 가지를 배우는 데 도움이되기를 바랍니다.
이 템플릿에서는 API 건물에 대한 지식을 실용적인 형식으로 수집했습니다. 모범 사례, 인기 및 내 의견이 많은 선호도에 따라 건축 선호도, 도서관 선택 및 기타 선택이 이루어집니다. 이 템플릿의 목적은 확장 가능하고 만족하기 쉬우 며 필요한 구성 및 기타 케이크를 포함하는 ASP.NET를 사용하여 REST API를 구축하는 방법에 대한 좋은 기본 예를 제공하는 것입니다. 이 템플릿은 Microsoft Eshoponweb Reference 응용 프로그램 및 기타 여러 가지에서 영감을 얻었습니다.
이 프로젝트는 MIT 라이센스가 부여되었습니다. 어쨌든 원하는 것을 자유롭게 사용하십시오. 제안과 도움을 환영합니다. ?