CSC309 Programming on the Web
Assignment 2 - Javascript, AJAX, JSON, JQuery, Node Rest API, Sqlite3

Due: March 6, 2018, 11:50 PM
Late penalty: 20% penalty for 48 hours late, not excepted after that.
Hand in: Electronic submit here
Preliminary Marking Scheme: here
Groups: Work in teams of size 2 (group app to appear shortly)
Environment:We will run your code under Firefox and the lab systems.

Warehouse Wars

Your job will be to implement the WareHouse Wars game as outlined in the CSC148 Assignment 1. This video is of a partial implementation.

Technologies

You will write your application using

Groups

Work in groups of size 2 (app to appear shortly)

Ports

Your web application should live at http://localhost:PORT/ You can find the ports you have been assigned here.

Starter Code

You can start with this starter code as well as the code in this lab (written just for you, for this assignment)

Installation Script

To install your application we will (on the lab machines): unzip ww.zip cd ww/db rm database.db # this is the database file!! sqlite3 database.db < schema.sql cd .. npm install mv OUR_PORT.js port.js nodejs ww_node.js

User Managment

Implement a user managment system with a RESTful api. Your api should support Account creation, update, delete and read via the appropriate http verbs POST, GET, PUT, DELETE. You should record users scores.

index.html

There is a single index.html which includes Javascript, JQuery, CSS etc. It has many different views. I have already placed starter code for this in static-content. To keep your code clean, you should probably separate the Javascript for this page into separate files. index.html has a few different parts, Homepage/Login, Account Creation/Modification, Game. All of these appear as a result of the single page load. The particular part of the page that the user sees depends in showing or hiding the appropriate div in Javascript/JQuery. Node should simply serve the static-content, and then the users interaction with the server is through the restful api only. The front end uses JQuery to make ajax requests to the backend. You will have to figure out what a AJAX JSON request looks like as well as what an AJAX JSON response looks like.

Homepage/Login

The home page contains a login form as well as a list of the top 10 high scores and a button/link etc. to the registration page. When the user selects registration, they are switched to that view of the same index.html. That is, no further request for html happens. Appropriate html inputs for login should be present. Validation should happen both on the front end and on the backend.

It should be noted that a RESTful api uses authentication slightly differently. That is, the simple case has the client store the credentials and repeatedly send them on each request. In this way, the server does not maintain session information. As an extra feature, you can implement rest api login pattern instead of simply sending the credentials on each request.

Account Creation/Modification

Accounts are validated both in the front end and the backend (in your node code). For backend validation, on invalid data, modify the css for form fields to let the user know where the issues are. A username can only appear in the database at most one time. Once a user is registered, they are placed on the game play page.

Game

Users can not see the game page without authentication. Yes, I know, in reality, since they have the javascript, they can hack it, but they still can't modify the backend information. Some more details are below...

References

Questions and Answers