DEV Community

Cover image for Late Hacktoberfest Part lV
Amir Helali
Amir Helali

Posted on

Late Hacktoberfest Part lV

Final Contribution

This is a post about my fourth and final contribution for this series. I am happy that I reached the goal of 4 contributions at the end. For my final contribution I wanted to work on a web application. First, I chose an issue that was about creating code syntax highlighting for a code translator application, when I started to work on this project I was having a lot of issues trying to get it to work because of the libraries I was trying to use and since I had spent a couple of days trying to get it to work and did not have enough time, I had to move on and choose a simpler web app issue to work on. But, I plan on going back to that project to keep working on it. So, I chose this issue. For this issue, the project owner wanted to implement a back-end functionality for his web application that was in charge of getting and sending a random quote from a data set and responding to the route associated with it. So, for the fourth time I reached out to be assigned the issue and started to work on it after I forked the repo.

Implementation

The implementation for this issue was easy. I created a function that located and read the json data file filled with quotes and I used "fs" and "path" modules to achieve that. After I read the file I parsed the json data and used the Math library to get a random index, then returned a random quote out of all the parsed quotes based on the random index that I had generated. Afterwards, I set up the app.get() method with the correct route for it, called the function I had created to retrieve a random quote inside it and returned it as a json response. I tested everything and made sure that everytime the route was called a new random quote was generated. After I was satisfied that everything was working and I did not break anything I committed my changes and created a PR.

What I learned

Even though I didn't get to fix the original issue that I had picked for my final contribution due to time constraints, I still plan on going back and working on it on my own time, because it piqued my interest. As for the issue I worked on, it was a nice review on express and back-end implementation. A new thing I learned though was not code related, it was Github related. When I was submitting my PR I saw that the project owner had set up their own PR form as a template, which was very interesting. This was the first time I had encountered a custom PR template when submitting one. I will consider using a custom PR template for my own projects, since it allows for more customization and organization of the PR details.

Top comments (0)