The endpoint for accepting/denying friend requests is at DELETE /api/friendRequests/ID. The use of DELETE may seem slightly unintuitive. However, the request is removed from the database when accepted or denied, thus the choice seems appropriate. Arguably, I could have used PUT instead, as the state of a user is updated/modified.
Sockets
As mentioned in a file from the course repo, using passport for authentication has some limitations with websockets. Another, token-based approach is used. In the timeline.jsx, I use something akin to this token-approach. In conversations.js, however, I use the passport-session to compare emails. My assumption is that for the purposes of this exam, showing two ways of doing something is better than showing one (or none).
General notes
Modifications to yarn scripts:
configuring yarn start to set environment variable. It indicates wether the server is running in development mode or not. This way, I may add demo data only when application is not in production.
notes about copying from course repo
Some files are completely copied. Others are copied, and later modified. This is differentiated in the comment.
JSON-format does not support comments. package.jsonis partially copied from this file
dependencies not used in course
eslint and related plugins. This is to create lint-config appropriate for the project (like support for React)
nanoid is used for generating random IDs. The library was updated recently, takes minimal amount of space, and has 700k weekly downloads.
cross-env is used for setting environment variables. I have access to a Mac. This should make sure that environment variable is working fine on non-UNIX systems as well
I could have written some functional components. In particular, smaller components with no state. However, I chose to stick with class based components for the sake of consistency. By "functional" and "class based", I am referring to the first and second example on this page, respectively.