tenongene / QuoteGen

0 stars 0 forks source link

Initial Quote Generator application design with NodeJS and Express #2

Open tenongene opened 10 months ago

tenongene commented 10 months ago

The challenge said it had provided an already containerized application. That did not seem to be available as it's an old repository. I decided to build my own from scratch using NodeJS, Express and some free APIs.

Image

Wrote a single page quote generator application using NodeJs and the Express framework. The page is intended to generate random inspiring quotes from a free quote API called Zenquotes (https://zenquotes.io). Along with the quote is displayed a random photograph of nature from a free photo collection API called Pexels (https://www.pexels.com).

A user will click on a "Generate" interactive button that will fetch a new picture along with a new quote with each call of the APIs.

Configured clicking of the "Generate" button to hit the "GET" route in express which will make sequential calls to the quote API, then the photo API, returning and resolving promises at each step to return the "picture", "quote" and "author" variables for injection into the page.

Masked the API key and Port Number using the dotenv module for security.

Made use of a random number function that generates a random number which I then attached as a variable to the API query string to generate a random quote/image.

tenongene commented 10 months ago

Image

Used the EJS templating engine to pass in the variables "picture", "quote" and "author" from the API that would be received from the APIs. I used simple styling from materialize css.

tenongene commented 10 months ago

Image

Initial pageview from localhost:7272 during development.