Skip to content

Latest commit

 

History

17 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

TP Backend -- Express, MongoDB, JWT, MVC

Description

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.


Technologies

  • Node.js
  • Express
  • MongoDB + Mongoose
  • JWT (JSON Web Tokens)
  • bcrypt
  • Thunder Client (API testing)

Installation

  1. Clone the repository:
git clone <repository-url>
  1. Install dependencies:
npm install
  1. Create a .env file based on .env.example.

Environment Variables

PORT=3000
MONGO_URI=mongodb://localhost:27017/tp-backend
JWT_ACCESS_SECRET=your_access_secret
JWT_REFRESH_SECRET=your_refresh_secret

Run the Project

npm run dev

The server will start on:

http://localhost:3000

Authentication Endpoints

Register

POST /api/auth/register

{
  "email": "user@test.com",
  "password": "123456"
}

Login

POST /api/auth/login

{
  "email": "user@test.com",
  "password": "123456"
}

Response:

{
  "token": "JWT_TOKEN"
}

Protected Endpoints (Tasks)

All protected routes require the header:

Authorization: Bearer JWT_TOKEN

Get Tasks

GET /api/tasks

Create Task

POST /api/tasks

{
  "title": "My first task"
}

Update Task

PATCH /api/tasks/:id

{
  "title": "Updated task",
  "completed": true
}

Delete Task

DELETE /api/tasks/:id


API Testing

All endpoints were tested using Thunder Client.
The exported collection is included in the repository.


Author

Tomás Taboada

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages