ruslanzharkov / nodejs-shopping-cart

NodeJS / Express / MongoDB - Shopping Cart (monolithic app with handlebars)

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Node js, Mongodb, Express js Shopping Cart

image

This project works with Stripe api on Nodejs and on the client representation as well. Go to Stripe for more information

Requirements

Used middlewares

  • connect-mongo
  • express cookie
  • nodemon
  • morgan

Migrations

Current app implementation doesn't have a UI for adding new products, but you can run script with migrations to add some products into DB and receive it from the application's UI. Make sure MongoDB is installed and running first.

npm run migration:write

ENV

Before running the app, you should create your own .env file in the root with the following variables:

PORT=<place your port here>
STRIPE_SECRET_KEY=<your stripe secret test key for server>
MONGO_DB_URL='mongodb://127.0.0.1:27017' or remote mongo address

Note: make sure to add publc stripe key to public/javascripts/checkout.js in order to configure both server and client parts of Stripe.

const stripePublishableTestKey = null;
// your public key should be here for proper Stripe work
// otherwise app generates en error with alert message

if (!stripePublishableTestKey) {
  const error = 'Please add a Stripe.js public key';
  alert(error);
  throw new Error(error);
}

Stripe.setPublishableKey(stripePublishableTestKey);

Running

  • npm install
  • add stripe test key to ENV file and to checkout.js (publishable not secret key for sender identification)
  • npm start
  • open browser at specified PORT env variables

About

NodeJS / Express / MongoDB - Shopping Cart (monolithic app with handlebars)


Languages

Language:JavaScript 63.8%Language:Handlebars 30.9%Language:CSS 5.0%Language:Shell 0.2%