- First, download this project from Moodle as a zip (yay, you’ve done that)
- Then, finish the steps below. Try and get as far as you can (but first read everything)
- Finally, create a zip from your project (include everything!) and hand it in on Moodle
In total, you can get 100 points in this project. How well you fare on each step, divided by 10, constitutes your grade for this assessment. If you finish step 4 (Express), you could pass this assessment, but mistakes in that step or earlier steps can still cause you to fail.
Note that for each step:
- You should do the requested thing
- Your code should not cause unhandled errors
- Your code should be valid and consistent
- Your code and thought process should be documented through code comments
Finally, you are allowed to use the internet while finishing this assignment, but not to communicate with each other. Using code found online is encouraged, but only allowed with citations!
Good luck! 👍👌💪
- Step 1: Init 10pt
- Step 2: Data 10pt
- Step 3: Templates 10pt
- Step 4: Express 30pt
- Step 5: HTTP 10pt
- Step 6: Forms 10pt
- Step 7: Images 10pt
- Step 8: Excel 10pt
Go to this project in your terminal, initialise a Git repository, commit the initial code, install the project’s dependencies, and start the server (it starts on port 1904).
Commit your changes for every following step.
Add three new countries to the data array in index.js
: places that you have
visited or would like to visit. For every country, add a name, continent,
capital, and a description of why to go there.
Finish the template to render all countries, view/list.ejs
. Render country
names, continents, and capitals. Create a valid and correct HTML table.
- [5pt] Add dynamic links from each country name in
view/list.ejs
to the corresponding detail page. Create links like so:/0
for The Netherlands (where0
is the parameter for the country to get and corresponds to its index in thedata
array; so/1
for the United States, and so on) - [15pt] Add the corresponding route in the server to render the country for
the links from the previous substep. Pass the correct data to the template
(
view/detail.ejs
), so that your route renders the correct corresponding country - [10pt] If a nonexistent country is requested, respond with the most relevant
status code and render the
view/error.ejs
template with correct data
Tip: Don’t forget to restart the server after you make a change.
Add support for removing a country.
There’s a delete button on the detail page of every country. This project
includes client-side JavaScript that, when the button is clicked, sends a
DELETE request to the corresponding country (so, if you’re on /0
, the
Netherlands, the button sends a DELETE to /0
). The client-side code will
redirect the user to the list of countries if the server responds with a
successful code.
Create a route in the server to handle these DELETE requests. Add code to
handle the request by removing the correct country (hint: use splice
to
remove something from an array). After removing a country, respond with the
most relevant status code and data. If the country at the corresponding index
does not exist, respond with the most relevant status code and data as well.
Tip: You cannot name a function delete
in JavaScript. Use something like
remove
instead. See MDN
for more info.
Create a form to add new countries. Use correct form elements. Make the form
POST to /
. Add a route in the server to handle the POST. After adding a
country, redirect to the new country.
Add support for uploading an image of the country and show that image instead of the map.
Make this project excellent, by:
- Adding support for updating countries
- Responding with data instead of HTML
- Using more parts of HTTP (other status codes or methods)
- Adding support for users, signing up, logging in, sessions, logging out
- Applying and enforce a code-style
- Writing great docs
- …or: doing something otherwise excellent, such as: