This project using .NET CORE 8 for the backend and database PostgreSQL.
There are several things you need to do before you can use this project.
- Install .NET Core 8
- Install PostgreSQL
- Install Docker (If you don't want to install PostgreSQL I suggest you install docker)
Since I'm not installing PostgreSQL so I will install PostgreSQL in Docker.
by execute this command in your terminal.
docker run --name tododb -e POSTGRES_PASSWORD=password -e POSTGRES_USER=postgres -e POSTGRES_DB=todo_db -p 5432:5432 -d postgresgit clone git@github.com:MarchelGunawan/back-end-todoitems.git
cd back-end-todoitemsdotnet add package BCrypt.Net-Next --version 4.0.3
dotnet add package Microsoft.AspNetCore.Authentication.JwtBearer --version 8.0.4
dotnet add package Microsoft.EntityFrameworkCore --version 8.0.4
dotnet add package Microsoft.EntityFrameworkCore.Design --version 8.0.4
dotnet add package Microsoft.EntityFrameworkCore.Tools --version 8.0.4
dotnet add package Npgsql.EntityFrameworkCore.PostgreSQL --version 8.0.3
dotnet add package Swashbuckle.AspNetCore --version 8.1.4To setting your own database connetion and key of JWT, you need to access file application.json and you will find something like this
{
"ConnectionStrings": {
"DefaultConnection": "Host=localhost;Port=5432;Database=postgres;Username=postgres;Password=password"
},
"Jwt": {
"Key": "supersecuresecretkeymustbe32bytes!",
"Issuer": "ToDoAppIssuer",
"Audience": "ToDoAppAudience",
"ExpireMinutes": 60
},
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft.AspNetCore": "Warning"
}
},
"AllowedHosts": "*"
}Before you start the application you need execute this command below for creating table based on Model that on this repo
dotnet ef migrations add InitialCreate
dotnet ef database updateTo run the application on your local machine you need execute this command
dotnet run --launch-profile httpsyou should be seen this after execute that command
info: Microsoft.Hosting.Lifetime[14]
Now listening on: https://localhost:7124
info: Microsoft.Hosting.Lifetime[14]
Now listening on: http://localhost:5291
info: Microsoft.Hosting.Lifetime[0]
Application started. Press Ctrl+C to shut down.
info: Microsoft.Hosting.Lifetime[0]
Hosting environment: Development
...To access the swagger documentation you can access it to
https://localhost:7124/swagger/