VerticalSliceMinimalApi 8.0.0

dotnet new install VerticalSliceMinimalApi::8.0.0                
This package contains a .NET Template Package you can call from the shell/command line.

Vertical Slice Minimal Api Template

Build

Getting Started

Install the template from Nuget Gallery

dotnet new install VerticalSliceMinimalApi::7.0.0

Local Development

  1. Clone the repository
git clone https://github.com/EnisMulic/VerticalSliceMinimalApi
  1. Install the template
dotnet new install ./VerticalSliceMinimalApi
  1. Use the installed template to create your API
dotnet new vsma --name ProjectName

Synopsis

dotnet new vsma --name [ProjectName]
    [-gh|--git-host [Github|AzureDevOps|None]]
    [-db|--database [MsSql|PostgreSql|None]]
    [-oa|--auth [Entra|None]]

Options

  • --name [ProjectName]
    Specify the name of the project you are creating, this will replace all occurrences of ProjectName in the template with the name you pass in.

  • -gh|--git-host [Github|AzureDevOps|None]
    Choose the platform you will host your projects git repository, this will give you a base CI workflow, pull request template, and anything specific to the platform that might be of use. The default value is None.

  • -db|--database [MsSql|PostgreSql|None]
    Choose what database to use for your project. The default is None

  • -oa|--auth [Entra|None] Choose a auth provider to use for your project. The default is None which will configure a JwtBearer Auth that you can use with dotnet user-jwts.

Configuration

Configure the application using appsettings.json, appsettings.Development.json or dotnet secrets

dotnet user-secrets init --project src/Api

Define Constants

To test/develop the template with specific options add a <DefineConstants> block to Directory.Build.props file.

<PropertyGroup>
  <TargetFramework>net7.0</TargetFramework>
  <Nullable>enable</Nullable>
  <ImplicitUsings>enable</ImplicitUsings>

  <AnalysisLevel>7-recommended</AnalysisLevel>
  <EnforceCodeStyleInBuild>true</EnforceCodeStyleInBuild>

+ <DefineConstants>UseDatabase;UseMsSql</DefineConstants>
</PropertyGroup>

How to Run

To start the app run:

dotnet run --project src/Api

Database

The template uses MsSql migrations by default, so if you select PostgreSql as your database you will need to remove the Application/Infrastructure/Persistance/Migrations folder and create a new migration script.

When you run the application the database will be created (if it doesn't exist) and the migrations will be applied.

To run the migrations you will need to add the following flags to your ef commands.

  • -p | --project src/Application
  • -s | --startup-project src/Api
  • -o | --output-dir Infrastructure/Persistance/Migrations

For example, to add a new migration:

dotnet ef migrations add \
  -p src/Application \
  -s src/Api \
  -o Infrastructure/Persistance/Migrations "MigrationName"
dotnet ef migrations add -p src/Application -s src/Api -o Infrastructure/Persistance/Migrations "MigrationName"

Auth

Generate a bearer token using dotnet user-jwts with optional roles and policies

dotnet user-jwts create
dotnet user-jwts create --role "Administrator"

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
8.0.0 202 4/13/2024
7.0.1 2,852 12/2/2023
7.0.0 211 12/1/2023