/TodoAPPBE-ExpressJS

This is a complete backend API ennpoint using express js.

Primary LanguageJavaScript


ToDo API with User Dashboard and Login Functionalities

This project is an Express.js API endpoint that provides ToDo management capabilities along with user dashboard and login functionalities. It uses various popular libraries and technologies like bcrypt, JWT, MongoDB, and nodemailer to achieve a secure and efficient user experience.

Prerequisites

Make sure you have Node.js and MongoDB installed on your system.

Installation

  1. Clone the repository:

    git clone https://github.com/Nwafor6/TodoAPPBE-ExpressJS.git
    cd TodoAPPBE-ExpressJS
  2. Install dependencies:

    npm install
  3. Set up environment variables:

    Create a .env file in the root directory and add the following environment variables:

    MONGODB_URI=YOUR_MONGODB_URI
    JWT_SECRET=YOUR_JWT_SECRET
    EMAIL_SERVICE=YOUR_EMAIL_SERVICE
    EMAIL_USER=YOUR_EMAIL_USER
    EMAIL_PASS=YOUR_EMAIL_PASSWORD

    Replace YOUR_MONGODB_URI with your MongoDB connection URI, YOUR_JWT_SECRET with a secret key for JWT, and YOUR_EMAIL_SERVICE, YOUR_EMAIL_USER, and YOUR_EMAIL_PASSWORD with your email service credentials for nodemailer.

  4. Start the server:

    npm start

API Endpoints

  • POST /signup

    Register a new user.

    Request Body:

    {
      "email": "user@example.com",
      "username":"Jogn",
      "password": "password"
    }
  • POST /login

    User login.

    Request Body:

    {
      "email": "user@example.com",
      "password": "password"
    }
  • PUT /update-profile/:id

    Uodate profile.

    Request Body:

    {
      "username":"Jogn",
      "password": "password",
      "new_password":"new_password"
    }
  • PUT /uploads/update-pic/:id

    Uodate profile image.

  • GET /

    Get all todos for the un-authenticated user.

  • GET /tasks

    Get all todos for the authenticated user.

  • POST /add-todo

    Create a new todo.

    Request Body:

    {
      "title": "Task Title",
    }
  • PUT /tasks/:id

    Update a todo by ID.

    Request Body:

    {
      "title": "Updated Task Title",
    }
  • DELETE /tasks/:id

    Delete a todo by ID.

Libraries and Technologies Used

  • Express.js - Web application framework for Node.js
  • bcrypt - Password hashing library
  • jsonwebtoken - JSON Web Token implementation
  • mongoose - MongoDB object modeling tool
  • nodemailer - Email sending library
  • dotenv - Environment variable management
  • cors - Cross-origin resource sharing middleware
  • multer - Middleware for handling multipart/form-data