https://github.com/moaraby/contact-manager-app-nodejs
Restful api app
https://github.com/moaraby/contact-manager-app-nodejs
authentication authroization crud-api expressjs javascript jwt mongodb nodejs
Last synced: about 1 year ago
JSON representation
Restful api app
- Host: GitHub
- URL: https://github.com/moaraby/contact-manager-app-nodejs
- Owner: MoARABY
- Created: 2024-04-09T23:55:00.000Z (almost 2 years ago)
- Default Branch: master
- Last Pushed: 2024-04-12T20:36:13.000Z (almost 2 years ago)
- Last Synced: 2025-01-01T18:43:41.885Z (about 1 year ago)
- Topics: authentication, authroization, crud-api, expressjs, javascript, jwt, mongodb, nodejs
- Language: JavaScript
- Homepage:
- Size: 29.3 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
Contact Management System - Backend
This repository contains the backend code for a contact management system built using Node.js, Express, and MongoDB.
Features
CRUD operations for managing contacts
User authentication and authorization using JWT and bcrypt
Middleware for request validation and error handling
Separation of concerns using controllers, models, and routes
Technologies Used
- Node.js
- Express.js
- MongoDB
- JSON Web Tokens (JWT) for authentication
- bcrypt for password hashing
- dotenv
- express-async-handler
- mongoose
- nodemon
Setup Instructions
- >Clone the repository:
- >> bash
- >> git clone https://github.com/your-username/contact-management-backend.git
Install dependencies:
- > bash
- > cd contact-management-backend
- > npm install
- > Create a .env file in the root directory.
- > Add the following environment variables:
- >> makefile
- >> PORT=3000
- >> MONGODB_URI=your-mongodb-connection-string
- >> JWT_SECRET=your-jwt-secret
Configure environment variables:
- > Start the server:
- >> bash
- >> npm start
API Endpoints
- POST /api/users/register: Register a new user.
- POST /api/users/login: Login with email and password to get JWT token.
- GET /api/contacts: Get all contacts.
- POST /api/contacts: Create a new contact.
- GET /api/contacts/:id: Get a contact by ID.
- PUT /api/contacts/:id: Update a contact by ID.
Folder Structure
- middlewares/: Custom middleware functions.
- controllers/: Request handlers for each route.
- models/: Mongoose schemas and models.
- routes/: Express routes for different endpoints.
Contributing
Contributions are welcome! Please fork the repository and submit a pull request.
License
This project is licensed under the MIT License.