https://github.com/yashsuthar00/nodejs-contact-manager-app
A Node.js backend application for managing contacts, featuring JWT-based authentication, CRUD operations with MongoDB, and secure API endpoints.
https://github.com/yashsuthar00/nodejs-contact-manager-app
backend express mongodb mongodb-atlas nodejs
Last synced: about 2 months ago
JSON representation
A Node.js backend application for managing contacts, featuring JWT-based authentication, CRUD operations with MongoDB, and secure API endpoints.
- Host: GitHub
- URL: https://github.com/yashsuthar00/nodejs-contact-manager-app
- Owner: yashsuthar00
- Created: 2024-12-16T18:51:42.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2025-01-09T19:58:37.000Z (over 1 year ago)
- Last Synced: 2025-06-04T15:02:15.601Z (about 1 year ago)
- Topics: backend, express, mongodb, mongodb-atlas, nodejs
- Language: JavaScript
- Homepage:
- Size: 35.2 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Contact Management System
A Node.js-based backend application designed to manage contact information efficiently. This project features user authentication and authorization using JWT, CRUD operations integrated with a MongoDB database, and secure API routes.
## Features
- **User Authentication & Authorization**:
- Register and log in users securely.
- Token-based authentication using JSON Web Tokens (JWT).
- Role-based access control for different levels of functionality.
- **CRUD Operations**:
- Create, Read, Update, and Delete contacts.
- Data persistence with MongoDB.
- **API Routes**:
- Organized and secure API endpoints.
- Authentication middleware to protect routes.
## Tech Stack
- **Backend**: Node.js, Express.js
- **Database**: MongoDB
- **Authentication**: JWT
## Installation
1. Clone the repository:
```bash
git clone https://github.com/yashsuthar00/nodeJs-CONTACT-MANAGER-APP.git
cd contact-management-system
2. Install dependencies:
```bash
npm install
3. Set up environment variables:
- Create a `.env` file in the root directory.
- Add the following keys:
```makefile
PORT=5000
CONNECTION_STRING=your-mongodb-connection-string
ACCESS_TOKEN_SECRET=your-jwt-secret
4. Start the server:
```
npm start
5. Access the application:
- Base URL: `http://localhost:5000`
## API Endpoints
### Authentication Routes
- **POST /api/users/register**: Register a new user.
- **POST /api/users/login**: Authenticate a user and return a JWT.
- **GET /api/users/current**: Shows the current authenticated user.
### Contact Routes
- **GET /api/contacts**: Get all contacts (protected).
- **POST /api/contacts**: Add a new contact (protected).
- **GET /api/contacts/:id**: Get a single contact by ID (protected).
- **PUT /api/contacts/:id**: Update a contact by ID (protected).
- **DELETE /api/contacts/:id**: Delete a contact by ID (protected).