loading...

MongoDB Web-Api Starter Template For `dotnet new`

djnitehawk profile image Đĵ ΝιΓΞΗΛψΚ Updated on ・1 min read

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

GitHub logo dj-nitehawk / MongoWebApiStarter

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

MongoWebApiStarter

A full-featured starter template for dotnet new to quickly scaffold a .Net Core 3.1 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

Features

Platform

  • base framework: .net core 3.1
  • api/web-service framework: servicestack
  • 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 with attribute decorators
  • custom middleware for putting site offline (maintenance mode)

Api Features

  • input validation with fluentvalidation rules
  • account creation, email validation, login
  • salted…

Discussion

pic
Editor guide