git-subtree-dir: backend git-subtree-mainline:ab911955edgit-subtree-split:040cfd7a75
110 lines
2.8 KiB
Markdown
110 lines
2.8 KiB
Markdown
# Hutopy
|
|
|
|
## Patterns / strategy used
|
|
- Clean Architecture ( with Infrastructure, Domain, Application and Web layers )
|
|
- Minimal API endpoints.
|
|
|
|
## Tools
|
|
- Install Docker : https://www.docker.com/get-started/
|
|
- Install sql server management ( or preferred tool ) : https://learn.microsoft.com/en-us/sql/ssms/download-sql-server-management-studio-ssms?view=sql-server-ver16#download-ssms
|
|
|
|
## Database setup in docker for local dev
|
|
```
|
|
docker run -e "ACCEPT_EULA=Y" -e "MSSQL_SA_PASSWORD=P@ssword123!" -p 1433:1433 -d mcr.microsoft.com/mssql/server:2022-latest
|
|
```
|
|
|
|
Or with a mounted volume to persist data on the computer instead ( persist data even if the container is deleted )
|
|
```
|
|
docker run -e 'ACCEPT_EULA=Y' -e 'MSSQL_SA_PASSWORD=P@ssword123!' -p 1433:1433 -v C:\dev\DockerVolumes\SqlServer-Utopy-1\data:/var/opt/mssql/data -v C:\dev\DockerVolumes\SqlServer-Utopy-1\log:/var/opt/mssql/log -v C:\dev\DockerVolumes\SqlServer-Utopy-1\secrets:/var/opt/mssql/secrets -d mcr.microsoft.com/mssql/server:2022-latest
|
|
```
|
|
|
|
## Postgres DB setup in docker for local dev
|
|
```
|
|
docker run -p 5432:5432 --name Hutopy -e POSTGRES_PASSWORD=P@ssword123! -e POSTGRES_USER=sa -d postgres
|
|
|
|
|
|
```
|
|
|
|
## Entity Framework
|
|
|
|
Create a new migration :
|
|
```
|
|
./Ef.ps1 migrations add NomDeLaMigration
|
|
```
|
|
|
|
Update database :
|
|
```
|
|
./Ef.ps1 database update
|
|
```
|
|
|
|
## Secret Manager tool
|
|
Go to Web project: cd src/Web
|
|
|
|
Add a user secret for local development :
|
|
```
|
|
dotnet user-secrets set "DB_PASSWORD" "12345"
|
|
```
|
|
|
|
list your stored secrets :
|
|
```
|
|
dotnet user-secrets list
|
|
```
|
|
|
|
Delete a secret :
|
|
```
|
|
dotnet user-secrets remove "DB_PASSWORD"
|
|
```
|
|
|
|
## Build
|
|
|
|
Run `dotnet build -tl` to build the solution.
|
|
|
|
## Run
|
|
|
|
To run the web application:
|
|
|
|
```bash
|
|
cd .\src\Web\
|
|
dotnet watch run
|
|
```
|
|
|
|
Navigate to https://localhost:5001. The application will automatically reload if you change any of the source files.
|
|
|
|
## Code Styles & Formatting
|
|
|
|
The template includes [EditorConfig](https://editorconfig.org/) support to help maintain consistent coding styles for multiple developers working on the same project across various editors and IDEs. The **.editorconfig** file defines the coding styles applicable to this solution.
|
|
|
|
## Code Scaffolding
|
|
|
|
Scaffold new commands and queries.
|
|
|
|
Start in the `.\src\Application\` folder.
|
|
|
|
Create a new command:
|
|
|
|
```
|
|
dotnet new ca-usecase --name CreateTodoList --feature-name TodoLists --usecase-type command --return-type int
|
|
```
|
|
|
|
Create a new query:
|
|
|
|
```
|
|
dotnet new ca-usecase -n GetTodos -fn TodoLists -ut query -rt TodosVm
|
|
```
|
|
|
|
If you encounter the error *"No templates or subcommands found matching: 'ca-usecase'."*, install the template and try again:
|
|
|
|
```bash
|
|
dotnet new install Clean.Architecture.Solution.Template::8.0.4
|
|
```
|
|
|
|
## Test
|
|
|
|
The solution contains unit, integration, and functional tests.
|
|
|
|
- Using Moq, Nunit, Respawn, FluentAssertions
|
|
|
|
To run the tests:
|
|
```bash
|
|
dotnet test
|
|
``` |