CRUD Restaurant Order Application With Node Js Server, Cart Functionality and Login/Register Functionality
- schema (Contains Order and User schema for the database)
- views
- assets (Contains All Javascript, Images and CSS Files)
- errors (Contains All Error Pages)
- pages (Contains All Pages)
- auth (Contains All Authentication Pages)
- order (Contains All Order Pages)
- restaurant (Contains All Restaurant Pages)
- user (Contains All User Pages)
- index.pug
- success.html
- database-initializer.js (Contains Database Initializer)
- package-lock.json
- package.json
- server.js
In this assignment I have create a web application that authenticates users and allows them to create, read, update orders. It also makes use of the MongoDB database to store Data
Node Package Used: pug, express, crypto, bycrypt, express-sessions, mongoodb, mongoose, connect-mongo
To be able to run the web application, you need to install the node modules
- Install Node Modules
npm install
- Start the Server
npm start
- Updates the Cart with Selected Procuts
- Implements Add to Cart and Remove from Cart
- Prompts user to checkeout when minimuim order amount has been reached
- Sends POST request and saves user order to Mongo Database
- Hashes User Password at Registration
- Stores User Information in Mongo Database
- Allows User to Login
- Allows User to Logout with error checking
- Allows User to Register
- Allows User to Update Profile
- Run the server with the following command:
npm start
- You should then see the homepage of the application as shown below:
- Open the browser and navigate to http://localhost:3000/
- You should see the following page:
- Now you can login with the following credentials:
Username: harry
Password: harry
-
Additionally, you can create your own user account by clicking the Register button
-
Registeration Page:
-
At default, all users privacy settings are set to false
-
Initially all users do not have any orders
- You can order using the following steps:
- Login
- Click the Order button
- Select Restaurant
- Select Products by clicking the add to cart button
- Chceckout
- NOTE: You can only access restaurant Menu and Cart once you have logged in
-
Initially all users do not have any orders
-
You can view your order history by clicking the profile button in the dropdown menu beside the username and you should see your order history
-
When you click on the order,you will see the order details
-
Sample page of orders:
- NOTE: If you're not logged in you will only be able to view order history of public users
- You can update your profile by clicking the profile button in the dropdown menu beside the username and you should see your profile as shown below
-
You should then click the edit profile button to edit your profile
-
You should then see an edit page like this:
-
NOTE: You can only update your profile if you are logged in. Also username and ID cannot be changed
-
Here you can also change privacy settings
-
You can view all users by clicking the Users button
-
NOTE: Only public users can be viewed
- You can logout by clicking the Logout in the dropdown from you
Done By: Dami Adesola