This project is a backend REST API built with Node.js, Express, and MongoDB, implementing JWT authentication and following the MVC (Model--View--Controller) architecture pattern.
It allows users to register, log in, and manage a protected entity (Tasks) associated with the authenticated user.
- Node.js
- Express
- MongoDB + Mongoose
- JWT (JSON Web Tokens)
- bcrypt
- Thunder Client (API testing)
- Clone the repository:
git clone <repository-url>- Install dependencies:
npm install- Create a
.envfile based on.env.example.
PORT=3000
MONGO_URI=mongodb://localhost:27017/tp-backend
JWT_ACCESS_SECRET=your_access_secret
JWT_REFRESH_SECRET=your_refresh_secretnpm run devThe server will start on:
http://localhost:3000
POST /api/auth/register
{
"email": "user@test.com",
"password": "123456"
}POST /api/auth/login
{
"email": "user@test.com",
"password": "123456"
}Response:
{
"token": "JWT_TOKEN"
}All protected routes require the header:
Authorization: Bearer JWT_TOKEN
GET /api/tasks
POST /api/tasks
{
"title": "My first task"
}PATCH /api/tasks/:id
{
"title": "Updated task",
"completed": true
}DELETE /api/tasks/:id
All endpoints were tested using Thunder Client.
The exported collection is included in the repository.
Tomás Taboada