I created this microservice as a requirement for my freeCodeCamp Information Security and Quality Assurance Certification, using Node.js, Express, MongoDB, Request, Chai, and Helmet. The front end API tests on the home page also use Bootstrap, jQuery, and highlight.js.
You can read the functional tests I wrote on GitHub or Glitch. To run the tests yourself, create a MongoDB database, fork/remix this project, create a .env
file with DB="{your MongoDB connection string}"
and NODE_ENV="test"
, start the server, and look at the server console logs.
This project fulfills the following user stories:
- Set the content security policies to only allow loading of scripts and css from your server.
- I can GET
/api/stock-prices
with form data containing a Nasdaqstock
ticker and recieve back an objectstockData
. - In
stockData
, I can see thestock
(string, the ticker),price
(decimal in string format), andlikes
(int). - I can also pass along field
like
astrue
(boolean) to have my like added to the stock(s). Only 1 like per IP should be accepted. - If I pass along 2 stocks, the return object will be an array with both stocks' info, but instead of
likes
, it will displayrel_likes
(the difference between the likes on both) on both. - A good way to receive current price is the following external API (replacing 'GOOG' with your stock):
https://finance.google.com/finance/info?q=NASDAQ%3aGOOG
- All 5 functional tests are complete and passing.