Swat009 / turingstore

A NodeJS based online store backend

Home Page:https://turingstore.herokuapp.com/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

TuringStore

This project contains a set of Express.js REST APIs which are intented to serve as the backend of an online shopping store. Sample endpoints are available here

Installation

Use the package manager npm to install all the requirements.

npm install 

Project structure

The app.js file is responsible for setting the enviromment, port, main app configurations and sequalize models associations.

The rest project files are divided into the following directories:

Controllers

The controller files contain the logic to handle requests for each api sections endpoint. e.g. products.js handles all /products api endpoint requests.

Routes

The route files direct requests to relevent controllers in the controllers directory. e.g. routes/products.js redirects requests to relevent controller function in controllers/products.js file.

Models

Contains sequalize model definitions of the various models used in the project.

Middleware

Contains the validation middlewares called in route files to valide requests before they reach controllers. Apart from a validater for each controller eg. productsvalidator for product controller there's a is-auth validator middleware used in routes to ensure only authenticated users can access some end points.

Logs

Contains the logs generated by winston.

Test

Contains files for each group of files eg. customers.js,products.js to run the API tests.

Util

Contains initialization codes for Sequalize, Passport, Express-Validator and Winston.

API Reference

All endpoints, inputs, and outputs are exactly as per this swagger documentation.

Usage

To use this backend in production the following environment variables need to be set:

        "USERNAME": Mysql database username,
        "PASSWORD": Mysql database password,
        "DATABASE": Mysql database name,
        "HOST": Mysql database host,
        "FACEBOOKCLIENTID": Facebook Client Id (For FB Login),
        "FACEBOOKCLIENTSECRET": Facebook Client Seckert (For FB Login),
        "JWTSECRETKEY": To encrypt JWT Tokens,
        "STRIPEKEY": Stripe Key to take payments

With these in place we can start the prod server with:

npm start

The dev environment variables can be set in the file nodemon.json in root directory of this project. The dev server can be run by the command:

npm run startdev

About

A NodeJS based online store backend

https://turingstore.herokuapp.com/


Languages

Language:JavaScript 96.9%Language:HTML 3.1%