Skip to content

lmnance2/Node-Express-Tutorial

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Node & Express Contact API

A RESTful Contact Management API built with Node.js, Express, MongoDB, and JWT authentication.

Project Status:

This project is a backend API created while learning the fundamentals of Express.js development. It demonstrates how to build a secure REST API with user authentication, CRUD operations, middleware, and MongoDB integration.


Features

  • User registration and login
  • JWT authentication
  • Password hashing with bcrypt
  • Protected API routes
  • Full CRUD operations for contacts
  • MongoDB database integration
  • Centralized error handling
  • Environment variable configuration

Technologies

  • Node.js
  • Express.js
  • MongoDB
  • Mongoose
  • JWT (JSON Web Tokens)
  • bcrypt
  • dotenv

API Endpoints

Authentication

Method Endpoint Description
POST /api/users/register Register a new user
POST /api/users/login Authenticate a user
GET /api/users/current Get the current authenticated user

Contacts

Method Endpoint Description
GET /api/contacts Get all contacts
GET /api/contacts/:id Get a single contact
POST /api/contacts Create a contact
PUT /api/contacts/:id Update a contact
DELETE /api/contacts/:id Delete a contact

Project Structure

mycontacts-backend/
├── config/
├── controllers/
├── middleware/
├── models/
├── routes/
├── server.js
└── package.json

Running the Project

Install dependencies:

npm install

Create a .env file:

PORT=5000
CONNECTION_STRING=<your_mongodb_connection_string>
ACCESS_TOKEN_SECRET=<your_jwt_secret>

Start the development server:

npm run dev

Or run normally:

npm start

Concepts Demonstrated

  • REST API design
  • Express routing
  • MVC architecture
  • Authentication with JWT
  • Password hashing
  • Middleware
  • MongoDB and Mongoose
  • Environment variables
  • Error handling

Development Status

Component Status
Authentication Complete
JWT Authorization Complete
Contact CRUD API Complete
MongoDB Integration Complete
Error Handling Complete

Purpose

This repository serves as a learning project for building secure REST APIs with Node.js and Express. It provides a solid foundation for developing larger backend applications that require authentication, database integration, and CRUD functionality.

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors