EMH.Templates.MVCAPI
1.0.12
dotnet new install EMH.Templates.MVCAPI@1.0.12
๐งฉ Templates ยท MVC API Project Template
A
dotnet newtemplate for ASP.NET Core MVC APIs that shows the Email Hippo project layout and coding standards.
This repo looks legacy/inactive. The template targets .NET 10 (retargeted from .NET Core 3.1 in November 2026).
โจ What it does
The repo is packed as the NuGet template package EMH.Templates.MVCAPI (short name emh-webapi). The src/ folder is the template content: a working web API with a "Hello World" demo that runs through every tier.
flowchart LR
C["Client"]
HC["HelloWorldController<br/>api/helloworld/v1"]
S["HelloWorldService<br/>(service tier)"]
M["Mappers<br/>(SimpleMapper)"]
P["HelloWorldProcessor<br/>(biz tier, MemoryCache)"]
R["HelloWorldReadOnlyRepository<br/>(retry policy, fake data)"]
C --> HC --> S
S --> M
S --> P --> R
| Tier | Example | Purpose |
|---|---|---|
| Host | HelloWorldController |
Validates input, calls the service tier, returns JSON, XML, BSON or protobuf |
| Service tier | HelloWorldService |
Maps service DTOs to biz DTOs and back; wraps the call in the IExceptionProcessor log-and-resume policy |
| Biz tier | HelloWorldProcessor |
Business logic; caches repository data in a MemoryCache for 10 minutes |
| Repository | HelloWorldReadOnlyRepository |
Data access stand-in; returns two hard-coded rows inside an exponential-backoff retry policy |
Other things the template sets up: SimpleInjector DI, Serilog with the HippoLog adapter, security headers (NetEscapades.AspNetCore.SecurityHeaders), an allow-all CORS policy, Swagger UI, and StyleCop analyzers.
๐ฆ Using this template
1. Install the template
dotnet new --install EMH.Templates.MVCAPI
2. Create a project from it
dotnet new emh-webapi -n {YourProjectName}
The template's sourceName is EMH.MVCAPI.Host.Web, so -n replaces that string. Then look for the // TODO: comments in Startup.cs (API name, Swagger description, your DI registrations) and remove the demo registrations.
๐ Quick start (working on the template itself)
Prerequisites
- .NET 10 SDK (the tests and the host run on the .NET 10 runtime).
- All packages, including
EMH.Lib.Patterns.*, restore from nuget.org.
Build, test, run
cd src
dotnet build EMH.MVCAPI.sln
dotnet test EMH.MVCAPI.sln
cd Hosts/EMH.MVCAPI.Host.Web
dotnet run
Run a single test class:
dotnet test --filter "FullyQualifiedName~HelloWorldProcessorTests"
๐ API
| Method | Route | Description |
|---|---|---|
| GET | / |
Returns Email Hippo API. |
| GET | /api/helloworld/v1/getmessage/{query} |
Demo endpoint. query must be 1โ255 chars. Returns a HelloWorldResult (Message, Error) |
| GET | /swagger/v1/swagger.json |
OpenAPI document (serialised as Swagger 2.0) |
| GET | /swagger |
Swagger UI |
The demo endpoint ignores query and always fetches item 1. Responses can be JSON, XML, BSON (application/bson) or protobuf (application/x-protobuf).
๐งช Testing
| Suite | Location | Needs |
|---|---|---|
| Unit | src/Tests/EMH.MVCAPI.Biz.Tests/BizTier/Unit, Core/Helpers |
Nothing |
| Integration | src/Tests/EMH.MVCAPI.Biz.Tests/BizTier/Integration |
Nothing today (the repository uses fake data) |
Tests use NUnit and Moq. TestBase sets up Serilog/HippoLog, an exception processor, and config from appsettings.json, environment variables and (Debug only) user secrets.
โ๏ธ Configuration
Settings come from appsettings.json, overlaid by appsettings.{Environment}.json and environment variables (standard ASP.NET Core host defaults).
| Key | Description |
|---|---|
AppConfiguration:Setting1 / Setting2 |
Example settings, bound to AppConfiguration and registered as a singleton |
Serilog |
Serilog sinks and minimum level (console sink by default) |
Logging:LogLevel |
Microsoft logging levels |
AllowedHosts |
Host filtering (*) |
๐๏ธ Project layout
build/
โโโ EMH.MVCAPI.nuspec Template package definition (EMH.Templates.MVCAPI)
โโโ pack.csproj Packs the nuspec with dotnet pack (nothing compiled)
โโโ icon.png Package icon
src/
โโโ .template.config/ dotnet new metadata (short name emh-webapi)
โโโ Business/EMH.MVCAPI.Biz/ netstandard2.0: service tier, biz tier, repos, mappers, helpers
โโโ Hosts/EMH.MVCAPI.Host.Web/ net10.0 web host: Startup, controllers, BSON/protobuf formatters
โโโ Tests/EMH.MVCAPI.Biz.Tests/ NUnit + Moq tests
โโโ EMH.MVCAPI.sln
bitbucket-pipelines.yml Pack and publish on release tags
๐ CI/CD
Bitbucket Pipelines (bitbucket-pipelines.yml) runs only on tags matching release-*. There is no build or test step for branches or PRs.
- Copies
src/topublish/content/, and the nuspec,build/pack.csprojandREADME.mdtopublish/. - Packs
EMH.Templates.MVCAPIwithdotnet pack(.NET 10 SDK) at version1.0.<build number>. - Publishes it to nuget.org through the shared
emailhippo/nuget-publisherscript (no API key in this repo).
The package is published to the public nuget.org feed. Anything in src/ ends up in it.
<sub>ยฉ Email Hippo Ltd</sub>
This package has no dependencies.
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
Initial commit.