Skip to content

This is an e-commerce back-end server built with NodeJs and MongoDB to serve an e-commerce front-end built with React.

Notifications You must be signed in to change notification settings

Mohannad35/e-commerce-api

Repository files navigation

E-Commerce-API

Table of Contents

About The Project

This is an e-commerce back-end server built with NodeJs and MongoDB to serve an e-commerce front-end built with React. The API documentation can be found at API Documentation. Front-end can be found at React Ecommerce Project.

Environmental variables

  • PROJECT_ISSUER (Name of the website that will be used when sending emails)
  • NODE_ENV (development, production, testing)
  • PORT (port number for the server to run on)
  • DEBUG (debug level)
  • MONGODB_URL (string url to mongodb cluster to connect to.)
  • ECOMMERCE_JWT_PRIVATE_KEY (JsonWebToken private key to encrypt user tokens)
  • LOGTAIL_SOURCE_TOKEN (LogTail souce token to use in logging function file middleware\logger.js)
  • SENDGRID_API_KEY (sendgrid api key used to send emails)
  • FACEBOOK_CLIENT_ID (client id from facebook developer account to implement facebook authentication)
  • FACEBOOK_SECRET_KEY (secret key from facebook developer account to implement facebook authentication)
  • FACEBOOK_CALLBACK_URL (url to function which will be called by facebook to get the user data)
  • GOOGLE_CLIENT_ID (client id from google developer account to implement google authentication)
  • GOOGLE_SECRET_KEY (secret key from google developer account to implement google authentication)
  • GOOGLE_CALLBACK_URL (url to function which will be called by google to get the user data)
  • DSN (DSN key from sentry for application performance monitoring and error reporting services)

Built With

Installation

  • First, you need NodeJS, MongoDB server (or online MongoDB Atlas) and preferably MongoDB compass to view changes in database, as well as internet connection (for the styling of the bootstrap) and at last an IDE to edit code you can use VScode. Links:

  • After installing:

    1. Clone or download the repository from GitHub
    2. Make a new file /config/.env and configure the Environmental variables as written or you will need to change their names in /config/custom-environment-variables.json.
    3. Open the project folder with VS code.
    4. In the integrated terminal, write the command npm install --also=dev to install the dependencies packages.
    5. (optional) To seed the database with samples for testing run npm run seed then go to MongoDB compass and see the results.
    6. Now run npm run dev in terminal to run the server.
    7. now you can call any API from postman or the front-end.

Run in Postman

Run In Postman