You are browsing as a guest. Sign up (or log in) to start making projects!

1h 39m 48s logged

Code cleanup

Quick summary

I refactored the NasaBot to improve code quality, readability, and maintainability by reducing duplicated code and separating common functionality into reusable functions.

Changes made

  • Configured a reusable Axios client for the NASA APOD API using a base url, api key, and request timeout
  • Created a fetchApod() function to retrieve APOD, removing duplicated API request code
  • Added formatExplanation() helper function to truncate long APOD descriptions to display in slack
  • Added a sendAPOD() function to format and send APOD responces, without repeated code
  • Better logging

Overall, after this rework, it should be much easier to add future features and maintain the bot.

0
7

Comments 0

No comments yet. Be the first!