This is an online-shopping website base on a WCC course. This project is built using MEAN Stack, AJAX and Bootstrap3.
Project Online demo is at https://shoppingcart.temptesting.com/
You can Re-Create the Project on Digital Ocean
-
Create a droplet with Ubuntu operating system under your Digital Ocean account
-
Root login after receiving the email from Digital Ocean with
ssh root@your ip address
-
Create a New User with
adduser USERNAME
-
Add your new user to the sudo group with
usermod -aG sudo USERNAME
Note : remember to log out and login with your new user. shouldn't run node with root.
-
You can also setup SSH access to the droplet, more info here
-
Set up the ufw firewall, more info here
-
Install node.js and npm on Ubuntu, better use nvm so you can switch between versions.
-
Installing MongoDB and secure it, more info here Or connect to a cloud mongodb database like the mongodb atlas
- Login to Mongodb with the admin user you created before
mongo -u USERNAME -p --authenticationDatabase admin
- Create your database and add a user to the database
show dbs
use classProject
db
db.createUser(
... {
... user: "DB_USER",
... pwd: "DB_PASS",
... roles: [ {role: "readWrite", db: "DB_NAME" } ]
... });
- Then Logout Mongodb, login with the new user you created, then create four collections for the project.
mongo -u CharlotteHale -p --authenticationDatabase classProject
db
use classProject
show collections
db.createCollection('admins');
db.createCollection('products');
db.createCollection('customers');
db.createCollection('orders');
- Create a initial first admin user and log out
db.admins.insert({ username: "firstuser", password: "$2b$10$90FnudVyfAwjiaRfETKvQunWB2/Fy4/jJBOJnGMCTXHh5LFnvdb6a"});
you can confirm the insert with db.admins.find().pretty()
NOTE: the password is using bcrypt hashing function to compute.
- Git clone the repo to your sever
- Create .env file and put in your MongoDB information NOTE the env file has not simicolon or other pucuation, it looks like
PORT = XXXX
DB_HOST = XXX.X.X.X
DB_NAME = Your DB NAME
DB_USERNAME = Your DB UserName
DB_PASSWORD = Your DB Password
- in the directory of the project run
npm install
- then run
node index.js
you should see
Server up : http://YOURSERVERIP:PORT
Mongoose Connected.
you can visit the webiste from the browser by typing http://yourserverip:port