loading...

MongoDB Web-Api Starter Template For `dotnet new`

github logo ・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. It comes with some commonly used features such as:

  • 3 Tier architecture
  • JWT token based authentication
  • Claim/Role/Policy 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 with MongoDB as the data store.

Install & Scaffold

  dotnet new -i MongoWebApiStarter
  dotnet new mongowebapi -n MyAwesomeApp

Features

Platform

  • framework: .net core 3.1
  • language: c#
  • database: mongodb

3 Layer Architecture

  • a single layer only references the layer immediately below it.
  • a layer has no idea about what's consuming it.

Api Layer

  • strongly typed app settings
  • JWT token authentication
  • policy based authorization
  • custom middleware for putting site offline (maintenance mode)

Business Layer

  • input validation with fluentvalidation rules
  • account creation, email validation, login
  • salted hash password storage and verification with bcrypt
  • email queue with background service for sending emails with smtp
  • image uploading

Data Layer

  • data access done using mongodb.entities library
  • data is modified & retrieved via repository classes

Integration Tests

  • uses mstest framework
  • uses fluentassertions
  • tests business logic via controller actions
twitter logo DISCUSS
Classic DEV Post from May 26 '19

How to Stay Fit Physically and Mentally and Keep Coding

Throughout the last year, I have worked part-time as a working student and also studied at the university. I was not the first and not the last one who has combined that during their studies, but the problem for me was, that at the end of the day I have felt absolutely exhausted mentally and physically. That caused problems with my health and motivation to continue working on my goals or anything. (yeah, “goals,” I wish I had something more specific at that time).

Đĵ ΝιΓΞΗΛψΚ profile image
Developer @ ChangeMon.com (Change Detection & Notification Service)