Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

a3-retat-Rene-Borner #5

Open
wants to merge 13 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added .DS_Store
Binary file not shown.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
*.DS_Store
node_modules/
package-lock.json
121 changes: 50 additions & 71 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,74 +1,53 @@
Assignment 3 - Persistence: Two-tier Web Application with Flat File Database, Express server, and CSS template
===

Due: September 16th, by 11:59 AM.

This assignnment continues where we left off, extending it to use the most popular Node.js server framework (express), a flat file database suitable for small applications (lowdb), and a CSS application framework / template of your choice (Boostrap, Material Design, Semantic UI, Pure etc.)


Baseline Requirements
---

Your application is required to implement the following functionalities:

- a `Server`, created using Express (no alternatives will be accepted for this assignment)
- a `Results` functionality which shows the entire dataset residing in the server's memory
- a `Form/Entry` functionality which allows users to add, modify, and delete data items (must be all three!) associated with their user name / account.
- Use of at least five [Express middleware packages](https://expressjs.com/en/resources/middleware.html). Explore!
- Basic authentication using the [Passport middleware](http://www.passportjs.org) for Express (this counts as one of your five middleware packages). We encourage using the Local strategy, but OAuth (Open Authentication) can also be used for additional technical achievement. The course staff cannot help you with the various flavors of OAuth strategies. YOU MUST PROVIDE US WITH ACCOUNT CREDENTIALS TO LOGIN TO YOUR APPLICATION IF YOU USE OAUTH. The course staff cannot be expected to have credentials for any particular OAuth service.
- Persistent data storage in between server sessions. [lowdb](https://github.com/typicode/lowdb) is a suitable database package for this assignment and will be discussed in class.
- Use of a [CSS framework or template](https://github.com/troxler/awesome-css-frameworks). This should do the bulk of your styling/CSS for you and be appropriate to your application. For example, don't use [NES.css](https://nostalgic-css.github.io/NES.css/) (which is awesome!) unless you're creating a game or some type of retro 80s site.

Your application is required to demonstrate the use of the following concepts:

HTML:
- HTML input tags and form fields of various flavors (`<textarea>`, `<input>`, checkboxes, radio buttons etc.)
- HTML that can display all data *for a particular authenticated user*. Note that this is different from the last assignnment, which required the display of all data in memory on the server.

Note that it might make sense to have two simple pages for this assignment, one that handles login / authentication, and one that contains the rest of your application. For this assignment, it is acceptable to simply create new user accounts upon login if none exist, however, you must alert your users to this fact. If you're not using OAuth

CSS:
- CSS styling should primarily be provided by your chosen template/framework. Oftentimes a great deal of care has been put into designing CSS templates; don't override their stylesheets unless you are extremely confident in your graphic design capabilities. The idea is to use CSS templates that give you a professional looking design aesthetic without requiring you to be a graphic designer yourself.

JavaScript:
- At minimum, a small amount of front-end JavaScript to get / fetch data from the server. See the [previous assignment](https://github.com/cs4241-19a/a2-shortstack) for reference.

Node.js:
- A server using Express, at least five pieces of Express middleware, and a persistent database (a flat file using lowdb is great).

Deliverables
---

Do the following to complete this assignment:

1. Implement your project with the above requirements. A good potential starting point is to use the "hello-express" project template inside of Glitch; this appears as an option when you hit the "New Project" button. Use the work you did in the last assignment as a reference to implement functionality, as well as the notes from class on 9/9 and 9/12.
2. If you developed your project locally, deploy your project to Glitch, and fill in the appropriate fields in your package.json file.
3. Test your project to make sure that when someone goes to your main page on Glitch, it displays correctly.
4. Ensure that your project has the proper naming scheme `a3-yourname` so we can find it.
5. Fork this repository and modify the README to the specifications below. You do not need to include any of your project files in this repo (we will see those on Glitch), you only need to update and commit the README file.
6. Create and submit a Pull Request to the original repo. Name the pull request using the following template: `a3-gitname-firstname-lastname`.

Sample Readme (delete the above when you're ready to submit, and modify the below so with your links and descriptions)
---

## Your Web Application Title

your glitch link e.g. http://a3-charlieroberts.glitch.me

Include a very brief summary of your project here. Images are encouraged, along with concise, high-level text. Be sure to include:

- the goal of the application
- challenges you faced in realizing the application
- what authentication strategy / database you chose to use and why (choosing one because it seemed the easiest to implement is perfectly acceptable)
- what CSS framework you used and why.
- include any modifications to the CSS framework you made via custom CSS you authored.
- the five Express middleware packages you used and a short (one sentence) summary of what each one does.
## Assignment App

With the Assignments Application an easy way is provided to how students keep track of all their assignments and due dates.
For the Assignment 3 I decided to update A2 in multiple ways.
![Application login](https://i.imgur.com/quSk5L4.png)

The application is reachable on https://a3-retat.glitch.me
To login the test user <br>
testAccount <br>
password <br>
can be used, or it's possible to create a new one by using the Sign up button.
![Application login](https://i.imgur.com/iBVQkVt.png)

- The goal of the application is to make the life of students easier by offering an easy solution for keeping track of all the assignments.
- One of the big updates is that now each user has his own set of assignments and cannot access the assignments of a different user.
- During the development of the application for A3 many problems occurred. I wanted to use a secure kind of authentication and therefore
decided to use an external DB (mongoDB) and hash/salt the passwords. The implementation of passport wasn't as straightforward as I expected,
but in the end everything worked out.
- I decided to use the local strategy of passport but save the user credentials in mongoDB. I used mongoDB because I really wanted
to use an external DB for security reasons and because I was interested in using a noSQL DB for the first time.
- I used the bootstrap CSS framework because I already have some experience in it and it offers a very rich feature set
- I didn't need to do any modifications to bootstrap because it already offers a wide variety of possible styles.
- The five Express middleware packages are the following:
- passport: Authentication service that makes it easy to authenticate a user and setup stuff like cookies
- body-parser: Used to parse HTTP request body
- serve-favicon: Serves the favicon and avoids 404 error messages
- compression: To compress HTTP responses
- serve-static: Serves files from a directory

## Technical Achievements
- **Tech Achievement 1**: I used OAuth authentication via the GitHub strategy
- **Tech Achievement 2**: I used over ten Express middleware packages, enabling me to create a server that...

- **Tech Achievement 1**: User and each users data (the assignments) are stored persistent in a mongoDB. The assignments are linked
to the user by the user id.
- **Tech Achievement 2**: Secure authentication by hashing and salting passwords and using cookies for a convenient login
- **Tech Achievement 3**: With the edit function Assignments get updated directly and not first deleted and then simply added again like
in A2
```javascript
collection.updateOne({
_id: new mongodb.ObjectID(parsedData.Id)
}, {
$set: {
"Note": parsedData.Note,
"Date": createDate(parsedData.Date),
"Days": daysRemaining(parsedData.Date)
}
}).then(r => collection.find({"UID": currentUser[0]._id}).toArray((err, items) => {
resolve(items)
}))
```
### Design/Evaluation Achievements
- **Design Achievement 1**: I tested my application using screen reading software, and found that...
- **Design Achievement 2**: I followed best practices for accessibility, including providing alt attributes for images and using semantic HTML. There are no `<div>` or `<span>` elements in my document.
- **Design Achievement 3**: We tested the application with n=X users, finding that...
- **Design Achievement 1**: I added a navbar for easy navigation, right now the user can use the logout function, whereas the
search function and the user Dashboard is still work in progress.
- **Design Achievement 2**: The login and register page are in the same style as the rest of the application.
- **Design Achievement 3**: With multiple users the application is stable and every user can access his own Assignments. Sometime the DB needs up to a second to answer but that's not too bad.
22 changes: 22 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"name": "",
"version": "",
"description": "",
"author": "",
"scripts": {
"start": "node server.js"
},
"dependencies": {
"bcrypt": "^3.0.6",
"body-parser": "^1.19.0",
"compression": "^1.7.4",
"express": "^4.17.1",
"express-session": "^1.16.2",
"mongodb": "^3.3.2",
"nodemon": "^1.19.2",
"passport": "^0.4.0",
"passport-local": "^1.0.0",
"serve-favicon": "^2.5.0",
"serve-static": "^1.14.1"
}
}
Binary file added public/.DS_Store
Binary file not shown.
9 changes: 9 additions & 0 deletions public/css/style.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
body {
font-family: "Verdana", Verdana, sans-serif;
}

.profile {
border-radius: 50%;
width: 20%;
}

85 changes: 85 additions & 0 deletions public/home.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
<!doctype html>
<html lang="en">
<head>
<title>René Borner CS4241 Assignment 2</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<link rel="icon" href="https://reneborner.de/favicon.ico">
<link rel="stylesheet" href="css/style.css">
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css">
<script
src=https://cdn.jsdelivr.net/npm/[email protected]/dist/fetch-json.min.js></script>
<script src="https://code.jquery.com/jquery-3.3.1.slim.min.js"
integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo"
crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.7/umd/popper.min.js"
integrity="sha384-UO2eT0CpHqdSJQ6hJty5KVphtPhzWj9WO1clHTMGa3JDZwrnQq4sF86dIHNDz0W1"
crossorigin="anonymous"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js"
integrity="sha384-JjSmVgyd0p3pXB1rRibZUAYoIIy6OrQ6VrjIEaFf/nJGzIxFDsf4x0xIM+B07jRM"
crossorigin="anonymous"></script>
</head>
<body>
<nav class="navbar navbar-expand-lg navbar-light bg-light">
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarSupportedContent"
aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>

<div class="collapse navbar-collapse" id="navbarSupportedContent">
<ul class="navbar-nav mr-auto">
<li class="nav-item active">
<a class="nav-link" href="#">Home <span class="sr-only">(current)</span></a>
</li>
<li class="nav-item dropdown">
<a class="nav-link dropdown-toggle" href="#" id="navbarDropdown" role="button" data-toggle="dropdown"
aria-haspopup="true" aria-expanded="false"></a>
<div class="dropdown-menu" aria-labelledby="navbarDropdown">
<a class="dropdown-item disabled" href="/dashboard">Dashboard (WIP)</a>
<a class="dropdown-item" href="/logout">Logout</a>
</div>
</li>
</ul>
<form class="form-inline my-2 my-lg-0">
<input class="form-control mr-sm-2" type="search" placeholder="Search" aria-label="Search">
<button class="btn btn-outline-primary my-2 my-sm-0" type="button"
onclick="alert('Search not implemented yet')">Search
</button>
</form>
</div>
</nav>
<div class="container text-center">
<img class="profile mt-2"
src="images/noteLogo.png"
alt="Application Logo">
<br>
<h1 class="display-3">
Hi
</h1>
<h3>
<small class="text-muted">I'm your assignments app</small>
</h3>
</div>
<div class="container mt-3">
<form action="">
<div class="row justify-content-around">
<div class="form-group">
<label for="inputAssignment">Assignment Content</label>
<input type="text" class="form-control col-12" id="inputAssignment" aria-
placeholder="Enter Assignment">
</div>
<div class="form-group">
<label for="inputDate">Date</label>
<input type="date" class="form-control col-12" id="inputDate" aria- placeholder="Enter Assignment">
</div>
<div class="w-100"></div>
<button id="add" class="btn btn-primary col-6">Submit</button>
</div>
</form>
</div>
<div class="container">
<ul class="list-group mt-3" id="notesContainer"></ul>
</div>
<script src="js/script.js"></script>
</body>
</html>
Binary file added public/images/.DS_Store
Binary file not shown.
Binary file added public/images/favicon.ico
Binary file not shown.
Binary file added public/images/noteLogo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
54 changes: 54 additions & 0 deletions public/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
<!doctype html>
<html lang="en">
<head>
<title>René Borner CS4241 Assignment 2</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<link rel="icon" href="https://reneborner.de/favicon.ico">
<link rel="stylesheet" href="css/style.css">
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css">
<script
src=https://cdn.jsdelivr.net/npm/[email protected]/dist/fetch-json.min.js></script>
<script src="https://code.jquery.com/jquery-3.3.1.slim.min.js"
integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo"
crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.7/umd/popper.min.js"
integrity="sha384-UO2eT0CpHqdSJQ6hJty5KVphtPhzWj9WO1clHTMGa3JDZwrnQq4sF86dIHNDz0W1"
crossorigin="anonymous"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js"
integrity="sha384-JjSmVgyd0p3pXB1rRibZUAYoIIy6OrQ6VrjIEaFf/nJGzIxFDsf4x0xIM+B07jRM"
crossorigin="anonymous"></script>
</head>
<body>
<div class="container text-center">
<img class="profile mt-2"
src="images/noteLogo.png"
alt="Application Logo">
<br>
<h1 class="display-3">
Hi
</h1>
<h3>
<small class="text-muted">You need to login</small>
</h3>
</div>
<div class="container mt-3 col-sm-4">
<form method='post' action='/login'>
<div class="form-group">
<label for="username">Username</label>
<input pattern=".{0}|.{4,15}" required
title="Username should be between 4 - 15 characters" id="username" class="form-control col-12"
type='text' name='username'/>
</div>
<div class="form-group">
<label for="password">Password</label>
<input pattern=".{0}|.{6,15}" required
title="Password should be between 6 - 15 characters" id="password"
class="form-control col-12" type='password' name='password'/>
</div>
<button class="btn btn-primary" type='submit' value='submit'>Login</button>
<button class="btn btn-danger" type="button" onclick="location.href='/register'">Sign up</button>
</form>
</div>
</body>
</html>
Loading