DEV Community

Francesco Menghi
Francesco Menghi

Posted on

Hacktoberfest #1

Hacktoberfest is here! I hope to make some good contributions and I will be sharing my experience on this blog as I move along.

After spending way too much time looking for a "Good First Issue", I found one that seemed interesting for my first contribution of the month.

The project I found is a tool that creates beautiful Github user stats to add to your profile's README. The project is called github-readme-streak-stats and it's written mostly in PHP.

The issue

The tool not only allows you to output the Github stats as an image, but also as JSON. The issue was that when an error occurred and the type was specified as JSON, the error output would still be an image instead of JSON.

The fix

The Pull Request I submitted included a fix for this problem. Here is what I added to the catch section of the code:

    if ($requestedType === "json") {
         // set content type to JSON
         header('Content-Type: application/json');
         // echo JSON error message
         echo json_encode(array("error" => $error->getMessage()));
         exit;
     }
Enter fullscreen mode Exit fullscreen mode

There was also another section where I added similar code to output a JSON error message. It took me some googling and some help from the project maintainer, since it was my first time working with PHP, but I am happy that my code worked and was merged!

Thoughts

What I really liked about this project was its documentation. They provided really easy and detailed instructions to get everything up and running. The only problem I had was related to a dependency called imagick. Installing it via Homebrew (macOS package manager) did not work so I was really happy when I found this guide that helped me install it from source (Looks like the problem was due to the fact that I am using an M1 Mac).

This was a great start to Hacktoberfest and I'm surely looking forward to getting involved in other neat projects.

Top comments (0)