MongoDB Web-Api Starter Template For `dotnet new`

djnitehawk

Dĵ ΝιΓΞΗΛψΚ

Posted on January 24, 2020

MongoDB Web-Api Starter Template For `dotnet new`

I've developed a dotnet new starter template for scaffolding a web-api project with mongodb. It was designed with ease of development and maintenance in mind. The level of complexity of the architecture is extremely low compared to what you'd typically see with N-tier architecture. The code should be self explanatory. Some features include:

  • Vertical slice architecture
  • JWT token based authentication
  • Claims & permission based authorization
  • Input validation
  • Password hashing
  • Email sending
  • Image uploading
  • Strongly-typed app settings
  • Integration tests

You can see the source code from the github repository below or simply install and scaffold a new project to play with using the following code:

    dotnet new -i MongoWebApiStarter
    dotnet new mongowebapi -n MyAwesomeApp
Enter fullscreen mode Exit fullscreen mode

GitHub logo dj-nitehawk / MongoWebApiStarter

A full-featured starter template for `dotnet new` to quickly scaffold an Asp.Net 6 Web-Api project with MongoDB as the data store.

MongoWebApiStarter

A full-featured starter template for dotnet new to quickly scaffold an Asp.Net 6 Web-Api project using pure vertical slice architecture with MongoDB as the data store.

Install & Scaffold

  dotnet new -i MongoWebApiStarter
  dotnet new mongowebapi -n MyAwesomeApp
Enter fullscreen mode Exit fullscreen mode

Features

Platform

  • base framework: .net 6
  • api/web-service framework: FastEndpoints
  • language: c#
  • database: mongodb

Vertical Slice Architecture

  • each use case/action/feature is isolated in it's own namespace (vertical slice).
  • there is no cross contamination between feature slices.
  • domain entities are contained in a seperate namespace as they are cross contaminating by nature.
  • does not use the mediator pattern like most other templates.

Misc. Features

  • strongly typed app settings which binds to appsettings.json
  • JWT token authentication with embedded claims & permissions
  • permission & claim based authorization
  • custom middleware for putting site offline (maintenance mode)

Api Features

  • input validation with fluentvalidation rules
  • account creation, email validation, login
  • salted hash password storage and verification…
💖 💪 🙅 🚩
djnitehawk
Dĵ ΝιΓΞΗΛψΚ

Posted on January 24, 2020

Join Our Newsletter. No Spam, Only the good stuff.

Sign up to receive the latest update from our blog.

Related