Skip to content

MarchelGunawan/back-end-todoitems

Repository files navigation

To Do List project documentation (.NET CORE 8)

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)

Installing PostgreSQL

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 postgres

Clone the repo

git clone git@github.com:MarchelGunawan/back-end-todoitems.git
cd back-end-todoitems

Install dependencies

dotnet 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.4

Setting connection and JWT

To 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": "*"
}

Migration Database

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 update

Run the application

To run the application on your local machine you need execute this command

dotnet run --launch-profile https

you 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
...

Access the swagger

To access the swagger documentation you can access it to

https://localhost:7124/swagger/

About

Backend application to do list item

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages