This repository is a practical ASP.NET Core Web API (.NET 8) solution that implements Onion Architecture
Presentation Layer:
- CompanyEmployees
- CompanyEmployees.Presentation
Infrastructure Layer:
- Repository
- LoggerService
Service Layer:
- Service
- Service.Contract
Domain Layer:
- Contract
- Entities
- HTTP methods: GET, POST, DELETE, PUT, PATCH, OPTIONS, HEAD
- Global error handling
- Validation attributes
- Asynchronous code
- Paging, Filtering, Searching, Sorting
- Data shaping
- Supporting HATEOAS
- Versioning
- Output caching
- Rate limiting
- Authentication & Authorization (JWT + refresh token)
- Documenting API with Open API
- .NET 8
- SQL Server
Run the following command in CMD with admin privilege to create secret key to sign/validate tokens.
setx WEB_API_SECRET "YourTopSecretKeyHasGreater256Bytes113211162023!!!!" /M
Provide your SQL Server connection string in CompanyEmployees\appsettings.json
In the solution directory, restore all the dependencies by the .NET CLI command:
dotnet restore
Navigate to CompanyEmployees directory, initialize the sample database:
dotnet ef database update
Start the app
dotnet run
Test the APIs by these commands:
curl https://localhost:5001/api/companies/c9d4c053-49b6-410c-bc78-2d54a9991870
curl https://localhost:5001/api/companies/c9d4c053-49b6-410c-bc78-2d54a9991870/employees
Open Swagger UI using a web browser to explorer the APIs at: https://localhost:5001/swagger/index.html