Supreme.Dotnet.Api.Template 1.3.0

dotnet new install Supreme.Dotnet.Api.Template::1.3.0
This package contains a .NET Template Package you can call from the shell/command line.

<img align="left" width="116" height="116" src="https://raw.githubusercontent.com/kapozade/dotnet-api-template/main/images/bricks.png" />

dotnet-api-template

Build CodeQL NuGet Package Supreme.Dotnet.Api.Template NuGet Package Downloads

Content

  1. Requirements

  2. How-to

    Installation

  3. Template Options

  4. Version History

  5. Contributors

The generated project implements Layered Architecture. Internal implementation uses CQRS principle to split query use cases from command use cases.

Supreme.Api: Responsible for showing information to user and interpreting user's commands.
Supreme.Application: Defines the jobs that project is supposed to do and directs expressive domain objects to work.
Supreme.Domain: Responsible for representing concepts of business, information about business situation and business rules.
Supreme.Infrastructure: Provides generic technical capabilities that support higher layers.
Supreme.Api.Tests: Provides you to add unit tests for API layer. It's up to you to enable integration tests at this layer.
Supreme.Application.Tests: Provides you to add both unit and integration tests for Application Layer. For integration tests currently TestContainers are being used. Depending on your choices, RabbitMQ, MySQL, PostgreSQL containers will be registered.
Supreme.Infrastructure.Tests: Provides you to add unit tests for Infrastructure Layer. It's up to you to enable integration tests at this layer.

<i>PS: When you name your project Supreme will be replaced with the name of project.</i>

  • DomainEvents, IntegrationEvents and outbox messaging can be used so as to have eventual consistency and strong consistency (requires enabled outbox pattern. Check Template Options).

  • You can add distributed rate limiting per endpoints. If you enable rate limiting, you can find rate limit types under Supreme.Api/Filters/RateLimits folder. Concurrent, Fixed Window, Sliding Window, Token Bucket rate limits are implemented. Currently, adding requests to queue when limit has been reached not supported.

[FixedWindowRateLimitFilter(policyKey: "foo", limit: 5, expireInSeconds: 60)]
[HttpGet("{id}", Name = "GetIndividualFoo")]
[ProducesResponseType(typeof(GetFooResponse), StatusCodes.Status200OK)]
public async Task<IActionResult> GetAsync([FromRoute] long id, 
    CancellationToken cancellationToken)
{
    var query = FooMapper.MapFrom(id);
    var result = await _mediator.Send(query, cancellationToken);
    var response = FooMapper.MapFrom(result);

    return StatusCode(StatusCodes.Status200OK, response);
}
  • You can enable open telemetry (Check Template Options).

  • You can define database by selecting one of the available options. (Check Template Options). Current options are PostgreSQL and MySQL. Default value is MySQL.

Requirements

The basic template depends on below resources.

  • .NET7
  • MySQL or PostgreSQL (depending on your choice)
  • Redis

If you would like to add outbox pattern functionality, you are required to have

  • RabbitMQ

You can find docker images for above resources via here

How-to

Installation

First, install template

dotnet new install Supreme.Dotnet.Api.Template

Run

## dotnet new supremeapi [options] [template options]
dotnet new supremeapi -n "MyService" -eop -eot -erl -db mysql

Template Options

Option Description
-f, --framework Currently net7.0 is supported. The default value is net7.0
-eop, --enable-outbox-pattern Enables outbox pattern by using CAP
-eot, --enable-open-telemetry Adds open telemetry configuration with Jaeger support
-erl, --enable-rate-limiting Adds basic rate limiting action filters that uses Redis behind
-db, --database The target database. mysql and postgres are supported. Default value is mysql

Contributors

Third Party Libraries

  • Ardalis.Specification
  • EasyCaching
  • FluentValidation
  • DotNetCore.CAP with RabbitMQ and MySQL or PostgreSQL (depending on your choice)
  • MediatR
  • Npgsql.EntityFrameworkCore.PostgreSQL
  • OpenTelemetry
  • Pomelo.EntityFrameworkCore
  • Scrutor
  • Serilog
  • StackExchange.Redis
  • Swashbuckle
  • Testcontainers

Credits

  • .NETStandard 2.1

    • No dependencies.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
1.3.0 3,320 12/23/2023
1.2.0 1,862 7/11/2023
1.2.0-rc.2 77 7/10/2023
1.2.0-rc.1 82 7/5/2023
1.1.1 1,721 6/30/2023
1.1.0 1,421 6/24/2023