Feedback for Timestamp Microservice

Hi everyone,

I completed my Timestamp Microservice API project.

Project: https://unemanja-timestamp.herokuapp.com
Github Repo: https://github.com/unemanja/timestamp-microservice

I would very much appreciate feedback for this project.

Thank you in advance!!

Hey unemanja, I would like to offer some feedback on your project.

First of all, congrats on getting this far - it’s a long road towards these later projects and your code looks really solid overall. I love that you took the time to add tests too.

There’s a fair bit of code here obviously, so I’ll just touch on a few key points that I think could be improved:

  • The routes folder seems more trouble than it’s worth - with only two routes, you’d probably be better off just wiring them up in server.js or in the controllers. The error route kind of breaks the pattern of the other too.
  • The core functionality of the service is hidden in the utils folder and it’s hard to make sense of the functions in there since they are called from another file. The controller does a bit too much for my taste. An alternative pattern to consider would be to have a timestamp service that is responsible for deciding which of your utils to use. The “utils” would ideally live in the same file so you can immediately see how they are used. The controller would then only pick the date_string from the request, call the conversion service and return its output as json.
  • Another benefit of this approach is that you can test the logic that is currently inside of the controller (the nested if-statements) much easier if it’s inside a simple function.
  • The first two functions in your utils file share a fair bit of code, so it would probably help to restructure them a bit. They are also a bit misleadingly named since they don’t return JSON - their output is just a JS object.

None of this is a huge issue though - overall this is in good shape I’d say.

A couple of general thoughts to finish off:

  • It doesn’t really matter while your working by yourself, but it’s a good habit to split your work into smaller commits so you can describe in the commit messages what you are doing and why. It makes it much easier to review your work.
  • If you haven’t already, maybe give typescript a try. There’s some overhead, but if you’re going through the trouble to write JS-docs already, I think you’d get more bang for your buck there.

I hope this is helpful - let me know what you think. Best of luck on your journey and happy coding!

1 Like

Hello faktotum85,

First, thank you very much for the feedback, it’s greatly appreciated.

  • I know that routes in a separate folder for the project this small are more trouble than, but I just like to have routes in the different folders.
  • I agree that the controller did too much and in future projects, I will try to implement a structure that you suggested in the future to see how it goes.
  • I know I put too many commit messages :frowning:
  • Last challenge in this part I allready started building in typescript.

Thank you again very much
Happy coding

1 Like