Treblle.NET.ApiBoilerplate
1.0.1-beta
dotnet add package Treblle.NET.ApiBoilerplate --version 1.0.1-beta
NuGet\Install-Package Treblle.NET.ApiBoilerplate -Version 1.0.1-beta
<PackageReference Include="Treblle.NET.ApiBoilerplate" Version="1.0.1-beta" />
paket add Treblle.NET.ApiBoilerplate --version 1.0.1-beta
#r "nuget: Treblle.NET.ApiBoilerplate, 1.0.1-beta"
// Install Treblle.NET.ApiBoilerplate as a Cake Addin
#addin nuget:?package=Treblle.NET.ApiBoilerplate&version=1.0.1-beta&prerelease
// Install Treblle.NET.ApiBoilerplate as a Cake Tool
#tool nuget:?package=Treblle.NET.ApiBoilerplate&version=1.0.1-beta&prerelease
.NET Core API boilerplate 🚀
An awesome boilerplate for your next .NET 6.0 based API. It's only goal is to simply kick-start your API development and provide you with some of the best practices when building amazing and scalable REST APIs 🔥
Features 🍭
REST API Best Practices
We baked in all the best REST API practices in terms of structuring your API, naming conversations, HTTP methods, responses and optimizations
Concrete examples
We all like to learn by examples and that's why the boilerplate comes with a concrete example that include everything from folder structure, routes to naming controllers
Built-in versioning
Building a versioning system that scales is always hard and that's why we built in a robust versioning system that is easy to use and can grow with the project</dd>
Minimal APIs
The boilerplate uses the new .NET 6.0 Minimal APIs architecture.
Clean Architecture
The boilerplate is loosly based on Clean Architecture patterns without being too strict. The endpoints are kept 'thin' by using the Mediator Pattern with Mediatr.
Entity Framework
Entity Framework Core is already included and we built two tables Users and Posts and defined everything you might need on a database and model level. You can easily expand the database by using the Entity Framework Migration system.
.NET Core Identity
Built in .NET Core Identity authentication using JWT Bearer tokens included in the boilerplate.
Validation
The boilerplate uses FluentValidation for consistent and scalable validation.
Easy exception handling
The boilerplate includes an example of a global exception handler which makes sure that the API always returns a user-friendly error message.
Treblle built-in
We added an awesome NuGet package called Treblle. Out of the box Treblle gives you: real-time API monitoring, automatically generated and updated documentation, error tracking and logging, API analytics, quality scoring and much more. To get started with Treblle visit treblle.com.
Project Structure
Core
The Core project contains the domain and business logic. This is where the entity models and everything needed to interact with them is defined. The interfaces for repositories are defined here but it's left to the Infrastructure layer to implement them.
Infrastructure
The Infrastructure project handles the communication with the database. It contains the implementations of the repositories defined in the Core project.
Presentation
The Presentation project implements the Minimal API and contains everything that's need to facilitate the communication with the consumer. API endpoints are defined here and user actions are mapped to queries and commands which are sent to the Core layer using the Mediator Pattern.
Requirements
Dependencies
- Entity Framework Core
- ASP.NET Core Identity
- Treblle for .NET Core
- Seriog
- Swashbuckle
- Mediatr
- AutoMapper
Getting started
You can install this template using the dotnet new CLI. To install the lastest version of the template run the following command.
dotnet new --install Treblle.DotNetApiBoilerplate.Template
Treblle
Create a FREE account on https://treblle.com to get an API key and Project ID.
Once you have your Treble API Key and Project ID you'll have to copy them into app.config
.
Database
The template was built for use with Microsoft SQL Server database, but it can easily be modified for any other database provider.
Make sure to edit the connection string in appsettings.json
.
JWT Bearer Token
Warning: Change the default secret key for JWT token generation, as well as Issuer and Audience in appsettings.json
before using this boilerplate for production apps.
Support
If you have problems of any kind feel free to reach out via https://treblle.com or email vedran@treblle.com, and we'll do our best to help you out.
License
Copyright 2022, Treblle Limited. Licensed under the MIT license: http://www.opensource.org/licenses/mit-license.php
Learn more about Target Frameworks and .NET Standard.
This package has 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 |
---|