Skip to content

Latest commit

 

History

History
84 lines (56 loc) · 5.65 KB

README.md

File metadata and controls

84 lines (56 loc) · 5.65 KB

Notes Backend API

This is a backend API for a Notes application built using Express.js. The API allows users to create, read, update, and delete notes, manage user accounts, authenticate users, and upload profile pictures.

Table of Contents

Dependencies

  • bcrypt: Used for hashing passwords before storing them in the database to enhance security.
  • dotenv: Loads environment variables from a .env file into process.env, allowing for easy configuration management.
  • express: A web framework for Node.js used to build the API endpoints.
  • jsonwebtoken: Used to create and verify JSON Web Tokens (JWT) for user authentication.
  • mongoose: An ODM (Object Data Modeling) library for MongoDB and Node.js, used for database interactions.
  • multer: A middleware for handling multipart/form-data, used for uploading user profile pictures.
  • nodemailer: Used to send emails, such as OTPs for user authentication.
  • otp-generator-random: Generates random OTPs for user verification.

Dev Dependencies

  • nodemon: A development tool that automatically restarts the Node.js application when file changes are detected.

API Endpoints

Note

  • POST /api/v1/note/create - Create a new note
  • DELETE /api/v1/note/d/:id - Delete a note by ID
  • GET /api/v1/note/all - Get all notes
  • GET /api/v1/note/g/:id - Get a single note by ID
  • PUT /api/v1/note/e/:id - Update a note by ID

User

  • POST /api/v1/user/generateOTP - Generate an OTP for user verification
  • GET /api/v1/user/details/:id - Get user details
  • PATCH /api/v1/user/update/:id - Update user password

Auth

  • POST /api/v1/auth/login - Log in a user
  • POST /api/v1/auth/register - Register a new user

Profile Picture

  • The API allows users to upload their profile picture via Multer middleware. The pictures are stored in the /uploads directory.

Setup and Installation

  1. Clone the repository:

    git clone <repository-url>
    cd <repository-directory>
  2. Install the dependencies:

    npm install
  3. Create a .env file by copying the .env.example file and filling in the necessary values:

    cp .env.example .env
  4. Fill in the .env file with your configuration values, such as database URL, JWT secret, PORT, email credentials, etc.

Running the Project

  1. Start the server using nodemon:

    npm run dev
  2. The server should now be running at http://localhost:PORT. You can test the API endpoints using Thunder Client, Postman, or any other API testing tool.