Question 2: node, REST api and SQLite3

file: vote/q2REST.js url: http://localhost:8000/api/lock/....

Create a restful api for the vote application. This time, votes are stored in a sqlite3 database. Each question has a qid, yesVotes and noVotes. You can find the schema in dbSchema.sql as well as dbInit.bash to init the database.

You can use q2REST_TEST.bash to test your q2REST.js. Note: It recreates the db with a few questions, stops and starts nodejs. To understand the rest api, take a look at q2REST_TEST_output.txt Your application should behave identically (with appropriate SERVER and PORT)

We will be looking for:

  1. Good error handling, set an appropriate return code and return an appropriate message
  2. Effective use of SQL and NODE/SQL api
  3. Clear understanding of the asynchronous nature of node
  4. Clear understanding of routing and route api
  5. Clear understanding of anonymous functions/arrow functions
  6. Effective use of javascript and javascript data structures
  7. Results conform to q2REST_TEST_output.txt

NOTE: Do not npm init or npm install. Everything you need is already here! All modules have already been installed.

NOTE: If you can't implement the server using the sqlite3 database, then, for reduced marks, modify the question so that you store the database in a javascript data structure in this node server.