Your first Host
Generate the monolith, start PostgreSQL, migrate, create a token, run the Host and call it.
What it is
The shortest path from an installed template package to a running Host that answers an authenticated call. It uses the monolith template, whose one Module is the Proving Sample's Catalog; the modular monolith runs the same way with more Modules to migrate.
The Host applies no migrations
Migrating is a step of its own, dotnet ef database update, run once per Module before the Host starts and again after each new migration. The Host also needs a bearer token's settings to start, which dotnet user-jwts writes for development.
When to use it
Right after you install the templates, with Docker running. Run each command from the folder you want the solution in, then from the solution's own folder as the steps say.
Run it
Generate the solution and restore its tools
dotnet new pouryakit-monolith -n Acme.Shop
cd Acme.Shop
dotnet tool restoreStart PostgreSQL
The connection string in the generated appsettings.json reaches this container.
docker run -d --name acme-shop-postgres -p 5432:5432 -e POSTGRES_PASSWORD=postgres postgres:18.6Migrate Catalog's database
The database need not exist: the update creates it before it applies the first migration.
dotnet ef database update --project src/Modules/Catalog/Catalog --startup-project src/Acme.Shop.Host --context CatalogDbContextCreate a development token
It writes the bearer settings the Host needs and prints a token. The tenant claim matters: Catalog is tenant-scoped, so its commands and queries refuse a caller without a tenant.
dotnet user-jwts create --project src/Acme.Shop.Host --claim tenant=acmeRun the Host
Trust ASP.NET Core's development certificate once per machine, since the https URL uses it, then run.
dotnet dev-certs https --trust
dotnet run --project src/Acme.Shop.HostIt listens on its launch profile's https and http URLs, which Running the generated Host lists.
Call it
In a second terminal, with the token from the step before. The answer is 200 with an empty Page of products.
curl -H "Authorization: Bearer <token>" http://localhost:5080/catalog/v2/productsIn Development the Host also serves its OpenAPI documents and the Scalar reference over them: Documents and Scalar.
Run the smoke test
The generated test project hosts the same Host against PostgreSQL in a container of its own, so it needs Docker but not the container above.
dotnet test --project tests/Acme.Shop.Tests/Acme.Shop.Tests.csprojWhen you are done, remove the container and its data:
docker rm -f -v acme-shop-postgresWhat the smoke test proves
| Behaviour | Stated in |
|---|---|
| A product created twice with one idempotency key is created once, and both calls get the same answer | The smoke test |
| The liveness endpoint answers a caller without a token from a Host composed as it is deployed | The smoke test |
| A Host whose permission checks are not registered does not build | The smoke test |