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.
Comments 0
No comments yet. Be the first!
Sign in to join the conversation.