Supreme.Dotnet.Api.Template 1.2.0-rc.2

This is a prerelease version of Supreme.Dotnet.Api.Template.
There is a newer version of this package available.
See the version list below for details.
dotnet new install Supreme.Dotnet.Api.Template::1.2.0-rc.2
                    
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.

<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);
}

Requirements

The basic template depends on below resources.

  • .NET7
  • MySQL
  • 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

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

Contributors

Third Party Libraries

  • Ardalis.Specification
  • EasyCaching
  • FluentValidation
  • DotNetCore.CAP
  • MediatR
  • OpenTelemetry
  • Pomelo.EntityFrameworkCore
  • Scrutor
  • Serilog
  • StackExchange.Redis
  • Swashbuckle

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,510 12/23/2023
1.2.0 1,945 7/11/2023
1.2.0-rc.2 148 7/10/2023
1.2.0-rc.1 159 7/5/2023
1.1.1 1,811 6/30/2023
1.1.0 1,508 6/24/2023