Skip to content

πŸ›’ A robust backend application that uses Node.js, Express, MongoDB, and integrate a 3rd-party API to enhance the functionality of the application (An E-commerce Platform).

Notifications You must be signed in to change notification settings

jxwatson251/E-Commerce-API

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

55 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

E-Commerce Backend API πŸ›’

Overview

This is a backend API service for an e-commerce platform built with Node.js, Express, and MongoDB. It features robust user authentication via JWT, secure password hashing with bcrypt, CRUD operations on products, and integration with a Currency Exchange Rate API to convert product prices into different currencies.

Project Structure

β”œ config/ β”œ controllers/ β”œ middleware/ β”œ models/ β”œ routes/ β”œ utils/ β”œ index.ts β”œ .env β”” package.json

Features

β€’ User Registration & Login β€’ JWT Authentication β€’ Password Hashing (bcrypt) β€’ Product CRUD Operations β€’ Currency Conversion using a 3rd-Party API β€’ Input Validation (Joi) β€’ Centralized Error Handling β€’ API Documentation with Swagger/Postman

Setup Instructions

Prerequisites

β€’ Node.js v16+ β€’ MongoDB β€’ npm or yarn

Installation

  1. Clone the repository https://github.com/jxwatson251/E-commerce-Platform.git cd E-commerce-Platform

  2. Install dependencies npm install

  3. Create a .env file PORT=5000 MONGODB_URI=mongodb://localhost:27017/ecommerce JWT_SECRET=your_jwt_secret EXCHANGE_API_URL=https://api.exchangerate-api.com/v4/latest/USD

  4. Start the server npm start

Authentication Endpoints

Endpoint Method Description
/api/auth/register POST Register a new user
/api/auth/login POST Login and receive JWT
/api/users/me GET Get user profile (auth)
/api/users/me PUT Update profile (auth)

Product Endpoints

Endpoint Method Access Description
/api/products GET Public Get all products
/api/products/:id GET Public Get product by ID
/api/products POST Authenticated Create a new product
/api/products/:id PUT Authenticated Update product (owner only)
/api/products/:id DELETE Authenticated Delete product (owner only)
/api/products/:id/price-in/:currency GET Public Get price in another currency

Validation & Error Handling

β€’ Request validation via Joi β€’ Centralized error middleware β€’ Meaningful HTTP status codes and messages

API Documentation

β€’ View the full API documentation via: β€’ Swagger UI (if implemented) β€’ Postman Collection: Link to Collection

About

πŸ›’ A robust backend application that uses Node.js, Express, MongoDB, and integrate a 3rd-party API to enhance the functionality of the application (An E-commerce Platform).

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published