This lab is worth 3 points.
Server-side development is more involved than what we have been doing so far and requires a number of components and software including Node.js and MongoDB (database). You may be using a database in part 3 of the ride-hailing service lab, but not in this lab.
For this class, we will deploy our server-side web application to Heroku. Why use Heroku you may ask? With Heroku, we do not need to worry about the server hardware, server configuration, and server maintenance. Server configuration and maintenance require an extraodinary amount of work. For a more elaborate discussion on Heroku vs Amazon AWS, see http://stackoverflow.com/questions/9802259/why-do-people-use-heroku-when-aws-is-present-whats-distinguishing-about-heroku.
Use the virtual machine (VM). You will also need to install the Heroku toolbelt on the VM on your own.
If you are a Mac user and choose not to use a virtual machine, install Node.js, Mongo DB, and the Heroku CLI (Command Line Interface) via Homebrew:
brew install node mongo
brew tap heroku/brew && brew install heroku
Install Node.js using directions at https://github.com/nodejs/node. Then, install MongoDB using directions at https://docs.mongodb.org/manual/administration/install-on-linux/. Finally, install Heroku CLI.
nodeto run Node.js (e.g.,
node index.js). On the virtual machine or on Linux, use
nodejsto run Node.js (e.g.,
node-js-getting-startedexample on GitHub: https://github.com/heroku/node-js-getting-started
In part 2 of the ride-hailing service lab, I provided a URL to send data to and in return, receive data on nearby vehicles,
https://hans-moleman.herokuapp.com/rides, a HTTP POST route. I will be decommissioning this resource after the lab is graded. Therefore, your map will no longer work. To make your map work again, you must recreate the server-side, the purpose of part 3 of the ride-hailing service lab.
index.js in your
node-js-getting-started so that it serves the following JSON when one accesses the route via
POST /rides, the following is returned as the response:
That is, a hard-coded JSON empty list.
https://[YOUR_APP_IDENTIFIER_RANDOMLY_GENERATED].herokuapp.com/rides on a web browser will not work (recall Quiz 1 and how web browsers work). However, if you make an HTTP POST request via
curl and send it any data, anything (e.g.,
curl --data "username=whocares" https://[YOUR_APP_IDENTIFIER_RANDOMLY_GENERATED].herokuapp.com/rides), the JSON string above will be the response.
Once you have completed this, change the URL
For this part of the lab, you are allowed to use additional Node.js modules although you really do not need to. You are strongly urged to continue building upon
node-js-getting-started for part 3 of the ride-hailing service lab. If you want to start a new repository on Heroku for part 3, you will also need to add me as a collaborator for that new Heroku app.
README.md file in
node-js-getting-started that describes your modifications. This description must:
Add me as a collaborator (using my email address
mchow[AT]cs[DOT]tufts[DOT]edu) for your web application in Heroku. You can do this by logging on to Heroku, go to the dashboard for your web application, under "Access", click on the "Add collaborator" button, enter my email address, and click "Save changes".
POST /rideswith JSON