ApodRoute

Astronomy Picture of the Day (APOD) route.

Constructor

new ApodRoute(router)

Creates an instance of the ApodRoute class.
Parameters:
NameTypeDescription
routerobjectThe Express router instance.

Methods

(async) getApod()

GET ./apod/list/:count
Retrieves the Astronomy Picture of the Day (APOD).
Parameters:
NameTypeDescription
req.params.countstringThe number of APOD entries to retrieve.
Returns:
  • 200 - Success - Returns an object with 'data' and 'error' properties.
  • 500 - Internal Server Error - An error occurred while processing the request.
Examples
Request:
GET http://localhost:5000/apod/list/1
Success response:
{
 "data": [
   {
     "title": "Galaxy Wars: M81 versus M82",
     "explanation": "In this stunning cosmic vista, galaxy M81 is on the left surrounded by blue spiral arms.  On the right marked by massive gas and dust clouds, is M82.  These two mammoth galaxies have been locked in gravitational combat for the past billion years.   The gravity from each galaxy dramatically affects the other during each hundred million-year pass.  Last go-round, M82's gravity likely raised density waves rippling around M81, resulting in the richness of M81's spiral arms.  But M81 left M82 with violent star forming regions and colliding gas clouds so energetic the galaxy glows in X-rays.  In a few billion years only one galaxy will remain.",
     "hdurl": "https://apod.nasa.gov/apod/image/0604/M81_M82_schedler_c80.jpg",
     "copyright": "Panther Observatory",
     "date": "2006-04-15",
   },
 ],
 "error": null
}
Error response:
{
 "data": null,
 "error": "An error occurred."
}

(async) getRandomImage()

GET ./apod/image
Retrieves a random image from the Astronomy Picture of the Day (APOD).
Returns:
  • 200 - Success - Returns the image stream.
  • 500 - Internal Server Error - An error occurred while processing the request.
Example
Request:
GET http://localhost:5000/apod/image