An open API service indexing awesome lists of open source software.

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

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.