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.
- bcrypt: Used for hashing passwords before storing them in the database to enhance security.
- dotenv: Loads environment variables from a
.env
file intoprocess.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.
- nodemon: A development tool that automatically restarts the Node.js application when file changes are detected.
POST /api/v1/note/create
- Create a new noteDELETE /api/v1/note/d/:id
- Delete a note by IDGET /api/v1/note/all
- Get all notesGET /api/v1/note/g/:id
- Get a single note by IDPUT /api/v1/note/e/:id
- Update a note by ID
POST /api/v1/user/generateOTP
- Generate an OTP for user verificationGET /api/v1/user/details/:id
- Get user detailsPATCH /api/v1/user/update/:id
- Update user password
POST /api/v1/auth/login
- Log in a userPOST /api/v1/auth/register
- Register a new user
- The API allows users to upload their profile picture via Multer middleware. The pictures are stored in the
/uploads
directory.
-
Clone the repository:
git clone <repository-url> cd <repository-directory>
-
Install the dependencies:
npm install
-
Create a
.env
file by copying the.env.example
file and filling in the necessary values:cp .env.example .env
-
Fill in the
.env
file with your configuration values, such as database URL, JWT secret, PORT, email credentials, etc.
-
Start the server using nodemon:
npm run dev
-
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.