This README provides documentation for the setup of the Note Management App. The backend is built using Node.js and Express.js, and it handles the creation, retrieval, updating, and deletion of notes.
- Node.js
- MongoDB
- npm (Node Package Manager)
-
Clone the repository
git clone https://github.com/DevanshChhabra/note-management-app.git cd note-management-app/backend
-
Install dependencies
npm install
-
Set up environment variables
Create a
.env
file in thebackend
directory with the following content:MONGO_URI=your_mongodb_connection_string JWT_SECRET=your_jwt_secret (for eg. afece612a7a8a0eff5a6192f68be52051c87ac3f70168ec998b8814eb2b077ab)
-
Start the server
npm start
-
Register a new user
POST /api/auth/register
- Body:
{ "name": "string", "email": "string", "password": "string" }
- Body:
-
Login a user
POST /api/auth/login
- Body:
{ "email": "string", "password": "string" }
- Body:
-
Create a new note
POST /api/notes
-
Headers:
x-auth-token: your_jwt_token
-
Body:
{ "color": "string", "content": "string", "title": "string", "date": "ISO 8601 date string" }
-
-
Get all notes for the logged-in user
GET /api/notes
- Headers:
x-auth-token: your_jwt_token
- Headers:
-
Update a note
PUT /api/notes/:id
-
Headers:
x-auth-token: your_jwt_token
-
Body:
{ "color": "string", "content": "string", "title": "string", "date": "ISO 8601 date string" }
-
-
Delete a note
DELETE /api/notes/:id
- Headers:
x-auth-token: your_jwt_token
- Headers:
-
authMiddleware.js
This middleware verifies the JWT token and adds the user information to the request object.
-
authController.js
Handles user registration and login.
-
noteController.js
Handles CRUD operations for notes.
-
User.js
Defines the user schema and model.
-
Note.js
Defines the note schema and model.
-
db.js
Handles the connection to the MongoDB database using Mongoose.
The frontend is build using react js and it's various libraries.
-
Navigate to the
frontend
folder:cd frontend
-
Install all dependencies:
npm install
-
Run the React app:
npm start