Skip to content

noecrn/nodejs-todo-api

Repository files navigation

📝 Epytodo

Epytodo is a backend REST API designed to manage a Todo List application. Built with Node.js and Express, it interacts with a MySQL database to manage users and their respective tasks.

🚀 Features

  • User Management: Registration and Login with secure authentication.
  • Task Management: Create, Read, Update, and Delete (CRUD) tasks.
  • Security:
    • Passwords hashed using bcryptjs.
    • Routes protected via JSON Web Tokens (JWT).
  • Architecture: Clean MVC-like structure separating routes, controllers, and database queries.

🛠️ Tech Stack

  • Runtime: Node.js
  • Framework: Express.js
  • Database: MySQL (via mysql2)
  • Authentication: JWT (jsonwebtoken)
  • Environment: dotenv

⚙️ Installation & Setup

1. Clone the repository

git clone [https://github.com/noecrn/epytodo.git](https://github.com/noecrn/epytodo.git)
cd epytodo

2. Database Setup

You need a MySQL server running. Import the provided SQL file to create the database and tables (user and todo).

mysql -u root -p < epytodo.sql

3. Environment Variables

Create a .env file at the root of the project with the following configuration :

MYSQL_DATABASE=epytodo
MYSQL_HOST=localhost
MYSQL_USER=root
MYSQL_ROOT_PASSWORD=yourpassword
PORT=3000
SECRET=your_jwt_secret_key

4. Install Dependencies

npm install

5. Run the Server

npm start

🔌 API Endpoints

Authentication

Method Endpoint Description
POST /register Register a new user
POST /login Log in and receive a JWT token

Users

  • Requires Authorization header with a valid Bearer Token.*
Method Endpoint Description
GET /user View currently logged-in user information
GET /user/todos View all tasks associated with the current user
GET /users/:id View specific user information
PUT /users/:id Update user information
DELETE /users/:id Delete a user

Todos (Tasks)

Requires Authorization header with a valid Bearer Token.

Method Endpoint Description
GET /todos View all todos
GET /todos/:id View a specific todo
POST /todos Create a new todo
PUT /todos/:id Update a todo
DELETE /todos/:id Delete a todo

📂 Project Structure

.
├── config/             # Database connection configuration 
├── middleware/         # Auth and Error handling middlewares 
├── routes/             # API Route definitions 
│   ├── auth/
│   ├── todos/
│   └── user/
├── src/                # Main source folder
├── .env                # Environment variables
├── epytodo.sql         # Database schema
├── index.js            # Entry point 
└── package.json

👥 Authors

Noé Cornu - Engineering Student @ EPITA

GitHub | LinkedIn

About

A robust RESTful API for a Todo List application built with Node.js, Express, and MySQL. Features JWT authentication, bcrypt password hashing, and complete CRUD operations for users and tasks.

Topics

Resources

Stars

Watchers

Forks

Contributors