

































Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
An assignment front sheet for a BTEC Level 5 HND Diploma in Computing. The assignment focuses on cloud computing and involves creating a web application in the cloud using Nodejs and PostgreSQL. instructions on configuring a cloud computing platform with a cloud service provider, connecting to PostgreSQL, and implementing a cloud platform using open-source tools. It also discusses the tools used for the project, such as Visual Studio Code and Heroku.
Typology: Essays (university)
1 / 41
This page cannot be seen from the preview
Don't miss anything!


































Qualification BTEC Level 5 HND Diploma in Computing Unit number and title Unit 16 : Cloud computing Submission date 11 /0 7 /2022 Date Received 1st submission Re-submission Date Date Received 2nd submission Student Name Võ Minh Quốc Student ID GCD Class GCD0904 Assessor name Tran Trong Minh Student declaration I certify that the assignment submission is entirely my own work and I fully understand the consequences of plagiarism. I understand that making a false declaration is a form of malpractice. Student’s signature Grading grid P5 P 6 P 7 P 8 M3 M 4 D2 D
Grade: Assessor Signature: Date: Internal Verifier’s Comments: Signature & Date:
In the last paper, we discussed some fundamental concepts of cloud computing. In here , we will create a web application in the cloud based on the approach I offered in my previous report. There is a Nodejs web application that uses PostgreSQL as a database. These projects will be deployed to the internet using Heroku.
Visual Studio Code: In layman's terms, Visual Studio Code is a code editor. Visual Studio Code is a "free editor that lets programmers write code, debug it, and repair it using the intelli-sense approach." In layman's words, it makes it easier for people to develop code. Many people believe it is half an IDE and half an editor, but the decision is entirely up to the developers. Any program or software we see or use is based on code that runs in the background. Traditionally, coding was done in traditional editors or even simple editors like notepad! These editors used to give rudimentary assistance to developers. Some of them were so primitive that building basic English level applications in them was quite tough. As time passed, some programming languages required a specialized structure and support for future coding and development, which these editors did not provide. One of the various types of editors that have emerged is VI Editor, often known as Sublime Text Editor. VISUAL STUDIO CODE is the most popular and supports practically every coding language. Its capabilities allow the user to customize the editor according on his needs, which means he may download libraries from the internet and combine them with the code as needed. The reasons why I choose Visual Studio Code for developing website:
But PostgreSQL is free on Heroku And PostgreSQL bring benefit to user when using it, PostgreSQL comes with many features aimed to help developers build applications, administrators to protect data integrity and build fault-tolerant environments, and help you manage your data no matter how big or small the dataset. In addition to being free and open source, PostgreSQL is highly extensible. For example, you can define your own data types, build out custom functions, even write code from different programming languages without recompiling your database!
C. Framework: I plan to utilize the express framework in this project. Express is a Node.js web application framework with a small yet robust feature set for online and mobile apps. Creating a strong API is quick and straightforward with a plethora of HTTP utility methods and middleware building at your disposal. Express delivers a robust set of fundamental web application functionality while without obscuring the Node.js features you already know and appreciate.
A. Deploying website to Heroku: Step 1: Create repository on Github Figure 2. Create repository Figure 1. Express framework
Figure 5. Result Step 3: Go to Heroku, click create new app Figure 6. Create new app on Heroku Step 4: Create new application with the name ‘node-js-heroku-app’
Figure 7. Choose name for app Step 5: Connect Heroku with repository NodeJSApp on Github Figure 8. Connect Heroku with repository on Github
Figure 11. Result Step 7: Click view to go to the website Figure 12. View website on Heroku platform This is the interface after deploying the website to heroku
Figure 13. Result Figure 14. Result Figure 15. Result
Figure 18. Connect PGadmin with Heroku Postgre Figure 19. Connect PGadmin with Heroku Postgre Step 4 : Create table and add data to table
Figure 20. Create table in PGadmin Step 5 : Run data clip to check if the Heroku database connected to the Postgresql database Figure 21. Result
I applied the MVC model for my project:
user: 'ktddxpmlrknzvh', host: 'ec2- 52 - 73 - 184 - 24.compute-1.amazonaws.com', database: 'deskkttup45o07', password: 'fbd9b1c6f8667bd44adf85f66528cf9e71b18b1b335f37d29b185b44d27fa377', port: 5432 , ssl:{ rejectUnauthorized: false } }) module. exports = pg_connection B. Authentication: This is code for the ‘Authenticated’ function in the class users.js, this part of code is a logic of this function, because it is in charge of authenticating which user login in. Firstly, we create the variable ‘uname’, and ‘passwd’ to receive the data from the request of user. Then we call the function ‘authen’ (from the authenticated.js class) then assigning the ‘uname’ and ‘passwd’ to this function, this ‘authen’ function have the key word ‘await’, it means ‘authenticated’ function will be left by the function containing the key word ‘async’ in order to do the next stuff, then the function containing ‘authen’ function will call the function ‘getTable’ (used for get table from the class ‘tableDisplay.js’ with the ‘await’ keyword and set it equal to the variable tableString. Finally the function will render the user.ejs class by transferring the data to that class for displaying if the function ‘authen’ returns true, by contrast, will return the message ‘wrong username and password, please enter again’ to force user enter again. var authen = require('../model/authenticated') var getTable = require('../model/tableDisplay') router.post('/', async function( req, res, next) { var uname = req.body.username var passwd = req.body.password var auth = await authen(uname, passwd) if (auth==true){ var tableString = await getTable(uname) // console.log(tableString.rows[0].role) res.render('user.ejs', { message: 'Login successfully', table: tableString })
}else{ res.render('login', {message: 'wrong username and password, please enter again'}) } }); Class tableDisplay.js is in charge of displaying the information of products depending on which user log in such as Boss, he/she can keep track of the data of all products but all shop in the company only reading the product data that they have from the database. const pg_connection = require('./pg-config'); async function getTable ( user){ const acc_query = { text: 'select role from users where username = $1', values: [ user] } console.log( user) var query_data = await pg_connection.query(acc_query) var role = query_data.rows[ 0 ].role; let table_query = {} if(role == 'boss'){ table_query = { text: 'select * from products' } }else{ table_query = { text: 'select * from products where shop = $1', values: [role] } } query_data = await pg_connection.query(table_query) var dataTable = query_data.rows var stringTable = "
| " + headerData[headerIndex] + " | " stringTable+=header } stringTable += "Delete |
|---|