DEV Community πŸ‘©β€πŸ’»πŸ‘¨β€πŸ’»

DΔ΅ ΞΞΉΞ“ΞžΞ—Ξ›ΟˆΞš
DΔ΅ ΞΞΉΞ“ΞžΞ—Ξ›ΟˆΞš

Posted on • Updated on

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…

Top comments (2)

Collapse
 
dejoie profile image
dejoie

Looks very good !Do you have any existing implementation (or sample/demo with source code available) somewhere on github ? Thanks for your answer

Collapse
 
djnitehawk profile image
DΔ΅ ΞΞΉΞ“ΞžΞ—Ξ›ΟˆΞš

this is the only open source project I can show you github.com/dj-nitehawk/VisitorLog

We are hiring! Do you want to be our Senior Platform Engineer? Are you capable of chipping in across sysadmin, ops, and site reliability work, while supporting the open source stack that runs DEV and other communities?

This role might just be for you!

Apply now