This is the backend of a simple ToDo application built with ASP.NET Core Web API. It supports:
- User registration and login
- JWT authentication with access and refresh tokens
- Route protection
- CRUD operations for tasks (ToDos)
- PostgreSQL database
- Swagger (OpenAPI)
- CORS configuration
- ASP.NET Core 8
- Entity Framework Core (PostgreSQL)
- PostgreSQL
- JWT Authentication
- Swagger / OpenAPI
- CORS
git clone https://github.com/maksh2504/dotnet-todo-api.git
cd dotnet-todo-api"ConnectionStrings": {
"DefaultConnection": "Host=localhost;Port=5432;Database=pas;Username=postgres;Password=root"
},
dotnet tool install --global dotnet-ef
Then apply migrations:
dotnet ef migrations add InitialCreate
dotnet ef database update
dotnet run
HTTPS: https://localhost:7175
HTTP: http://localhost:5274
Available at: https://localhost:7175/swagger
For protected routes, pass the access token in the Authorization header like:
Authorization: Bearer <your_token>
POST /api/auth/register
{
"username": "string",
"password": "string"
}
POST /api/auth/login
{
"username": "string",
"password": "string"
}
POST /api/auth/refresh
{
"refreshToken": "string"
}
GET /api/users/current
GET /api/api/todos
Query: {
"sort": "asc" | "desc",
"finished": "empty" | "true" | "false"
}
POST /api/api/todos
{
"title": "string",
"description": "string",
"finished": true
}
GET /api/api/todos/{id}
PATCH /api/api/todos
{
"title": "string",
"description": "string",
"finished": true
}
Delete /api/api/todos/{id}