GithubHelp home page GithubHelp logo

modularwebtemplate's Introduction

Modular Web Template

Have you ever noticed how the vast majority of "getting started" code samples for ASP.NET Core simply do not scale at all? How minimal APIs are very easy to get started with and then become very messy very quickly? How the configuration of the WebApplication builder creates code snippets that should be together but aren't? How you end up solving the same basic problems of integrating the same libraries in every new ASP.NET Core project?

If so, then you might be interested in this template. This project is a template in the more traditional sense. While it can be used to quickly get a structured project off the ground, its main purpose is to provide a much more complete code sample for an ASP.NET Core application that provides a maintainable structure.

At the core of the project is a modular system of aspects which are cross-cutting concerns of most web applications like validation, authentication, OpenAPI documentation, etc. These aspects are using a simple IAppConfigurationModule interface to encapsulate the necessary configuration in the form of modules that are then registered in the AppServer which creates a much more readable and maintainable code structure.

The template can of course easily be customized by simply removing the things that are not needed or changing them to fit your needs. If the SPA module is not needed, remove it. If you are using a different authentication mechansim than JWT bearer tokens, change the code in the AuthModule.

Features

  • Authentication using JWT bearer tokens - see the appSettings.json for configuration
  • CORS configuration for API endpoints that can be used from a separate or integrated SPA application
  • More reasonable defaults for the JSON serialization configuration
  • OpenAPI documentation for API endpoints using Swagger
  • Validation of incoming DTOs using FluentValidation
  • ASP.NET Core controllers configuration with custom injectable settings - see appSettings.json
  • SPA routing with custom middleware that routes all unhandled requests to a central location like /index.html for Angular apps
  • Automatic versioning based on git tags
  • Status endpoint for version information and health check /v1/status

Instantiate with dotnet new ...

The template can easily be used as a template with the dotnet new command. To do that, you first need to install it.

  1. Clone the repository
  2. In the terminal, naviate to the WebTemplate directory
  3. Run dotnet new install . - add the --force flag to update the installed template with a newer version of the source

After that, you can instantiate a new project like this.

dotnet new modweb -o MyNewProject
cd MyNewProject
git init
git add .
git commit -m "Initial commit with code from "https://github.com/lord-executor/ModularWebTemplate"
dotnet run

modularwebtemplate's People

Contributors

lord-executor avatar

Stargazers

seyli avatar Daren Thomas avatar

Watchers

 avatar seyli avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.