Routing middleware is added to the request pipeline & attribute routing
is used.
API gets & manipulates data from API endpoints, using the built-in dependency injection system. Endpoints are decorated with appropriate Http
attributes: Get, Post, Patch, etc…
Endpoints return async Task
s to free up threads to be used for other tasks, improving the application's scalability.
ICityInfoRepository.cs
: Repository Pattern is implemented.
Automapper
is used to map between Entites
& DTOs
(Profiles
folder).
Check GetCitiesAsync(string? name, string? searchQuery, int pageNumber, int pageSize)
for searching & paging.
IQueryable
is used for deferred execution: query is constructed with passed filters & executed in the end when iterated over with ToListAsync()
.
Connects to SQL
database via Entity Framework Core 8
with code-first approach.
API is documented with Swagger
.XML comments
are used to make it more descriptive: Response Types
& Status Codes
. (Check GetCity
endpoint in CitiesController.cs
for a sample.)
CityInfoApiBearerAuth
security definition (type: “Http”, scheme: “Bearer”
) is required (check builder.Services.AddSwaggerGen
in Program.cs
). Sample jwt
is generated in AuthenticationController.cs
.
Versioning via URI.