Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

NishadAnwar/Contact_Management-API

Open more actions menu

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Contact-Management-API (Node.js, Express, MongoDB, JWT)

A secure RESTful API for managing personal contacts with user authentication, built using Node.js, Express, MongoDB (Mongoose), and JWT. It supports user registration/login and full CRUD for contacts, with ownership-based authorization to ensure each user can access only their own data.

Features :

-> User authentication with JWT (login, protected routes)

-> Secure password hashing with bcrypt

Contacts CRUD:

-> Create, read (list and by id), update, delete

-> Scoped to the authenticated user via user_id

-> Centralized error handling

-> Clean route separation and middleware-driven auth

Tech Stack

-> Runtime: Node.js, Express

-> Database: MongoDB with Mongoose

-> Auth: JSON Web Tokens (JWT), bcrypt

-> Utilities: express-async-handler, dotenvFeatures

-> User authentication with JWT (login, protected routes)

-> Secure password hashing with bcrypt

Project Structure

/config

-> dbConnection.js — MongoDB connection

/controllers

-> userController.js — register, login, current user

-> contactController.js — contacts CRUD with ownership checks

/middlewares

-> verifyTokenHandler.js — JWT validation, attaches req.user

-> errorHandler.js — centralized error formatter

/models

-> user-model.js — User schema (username, email, password)

-> contact-model.js — Contact schema (user_id, name, email, contact)

/routes

-> userRoute.js — /api/users

-> contactRoute.js — /api/contacts (protected)

index.js — App entrypoint, middleware and routes wiring

Getting Started

Prerequisites

-> Node.js >= 16

-> MongoDB instance (local or cloud)

-> npm or yarn

Installation

1. Clone the repository

-> git clone your-repo-url

-> cd repo-name

2. Install dependencies

-> npm init

3. Configure environment variables

-> Create a .env file in the project root:

-> PORT=3000

-> MONGO_URI=mongodb://localhost:27017/contacts_db

-> ACCESS_TOKEN_SECRET=your-very-strong-secret

About

A secure RESTful API for managing personal contacts with user authentication, built using Node.js, Express, MongoDB (Mongoose), and JWT

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Morty Proxy This is a proxified and sanitized view of the page, visit original site.