DotNetCoreBaseAPI 1.1.1

dotnet add package DotNetCoreBaseAPI --version 1.1.1
                    
NuGet\Install-Package DotNetCoreBaseAPI -Version 1.1.1
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="DotNetCoreBaseAPI" Version="1.1.1" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="DotNetCoreBaseAPI" Version="1.1.1" />
                    
Directory.Packages.props
<PackageReference Include="DotNetCoreBaseAPI" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add DotNetCoreBaseAPI --version 1.1.1
                    
#r "nuget: DotNetCoreBaseAPI, 1.1.1"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package DotNetCoreBaseAPI@1.1.1
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=DotNetCoreBaseAPI&version=1.1.1
                    
Install as a Cake Addin
#tool nuget:?package=DotNetCoreBaseAPI&version=1.1.1
                    
Install as a Cake Tool

DotNetCoreBaseAPI

This class library can be used as base api to import various basic configuration for consumer api. It also contains a test consumer api to execute library locally. Dot Net Version: 8.0

This library provides below features.

  1. Registers different configuration files (appSettings.json) per environement. (Development, Production)
  2. Provided with specific logger provider (Serilog, NLog, Log4n etc), register logger configuration. (Update in progress...)
  3. Provides different authentication services based on provided auth provider from consumer apis. (None, Basic, JWT, Token, OAuth)
  4. Provides SwaggerGen and Swagger UI for consumer api testing
  5. Provides APiVersioning support if needed.
  6. Provides Polly retry policies for HttpClient calls from consumer APIs.
  7. Provides multiple HttpClient registration.
  8. Provides different types of health checks for consumer apis. Default health check endpoint is "api/health". More details about health check is in instruction below.

Instructions for consumer APIs

Base API Metadata

Provide DotNetCoreBaseAPI.Models.BaseApiConfigurationMetaData as parameter while calling builder.CreateWebApplicationBuilder to provide different services needed for consumer api.

Healthchecks

Provide heath check configurations in consumer's appSettings.json in below format. "HealthChecks":{ "UriGroup":"<Custome uri group url for URi heal check>", "RemoteUris":[ "List of remote uris for remote endpoints health checks" ] }

Logger Configurations

  1. Add LogFilePath config under Logging in appSettings.json. "Logging": { "LogLevel": { "Default": "Information", "Microsoft": "Warning", "Microsoft.AspNetCore": "Trace", "System": "Error" }, "LogFilePath": "Logs" // ⇐=== This value }

Polly Retry Settings

  1. Add Polly retry settings in Consumer API's appSettings.Json. Refer below as example.

    "PollySettings": { "DefaultPolicy": "Immediate", //Single value either from Immediate|Linear|Exponential "RetryCount": "5", //Number of retries "RetryInterval": 3 //In seconds }

  2. In case above settings are not provided by consumer api, default policies configured will be Immediate, Linear and Exponential with retry count as 5 and retry interval as 3 seconds, else all three policies are configured using "RetryCount" and "RetryInterval" values provided.

  3. Above settings are used to decide retry policy to make http calls using "DefaultPolicy".

Consumer Service Registration

  1. Consumer APIs can implement "IServiceMarker" from base api to automatically register consumer's services to service collection. Refer below sample service creation for automatic registration.

public class MyService : IMyService, IServiceMarker ⇐= base service interface {}

Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.