https://github.com/hurricanemark/stockpricechecker
Use https://stock-price-checker-proxy.freecodecamp.rocks/ to get up-to-date stock price information without needing to sign up for API key
https://github.com/hurricanemark/stockpricechecker
Last synced: 3 months ago
JSON representation
Use https://stock-price-checker-proxy.freecodecamp.rocks/ to get up-to-date stock price information without needing to sign up for API key
- Host: GitHub
- URL: https://github.com/hurricanemark/stockpricechecker
- Owner: hurricanemark
- Created: 2022-06-01T17:16:37.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2022-06-15T18:08:59.000Z (over 3 years ago)
- Last Synced: 2025-03-22T04:13:00.394Z (8 months ago)
- Language: JavaScript
- Size: 289 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Stock Price Checker
Instructions for building your project can be found at [Information Security Projects -- Stock Price Checker](https://freecodecamp.org/learn/information-security/information-security-projects/stock-price-checker)
This project has a standard layout initialized by command **npm init -y**
One should look at *package.json* for top down information.
Backend: The *server.js* drives the backend service logics in */routes/api.js*
MongoDB is implemented as the event driven database. You must set your own MongoDB connection string in *dotenv* to enable data storage logic.
The remaining code in */tests/* is dedicated to testing. Set identifier NODE_ENV in *dotenv* to *test*.
Frontend: The front-end code is in */views/index.html* and */public/script.js*
Note:
Data source is fetched from an API proxy setup by freecodecamp. i.e. Not real life stock data!!! To make it shows real life stock data, simply replace the fetching URI with access token from your stock market API provider.
## Upgrade nodejs to 15.14.0
This project requires nodejs 15 to resolve ES6 import issue. Run the command below.
```
npm init -y && npm i --save-dev node@15 && npm config set prefix=$(pwd)/node_modules/node && export PATH=$(pwd)/node_modules/node/bin:$PATH
```
Declare identifier as follow to resolve ES6 error message '... import outside of module...'
```
const anonymize = (...args) => import('ip-anonymize').then(({default: anonymize}) => anonymize(...args));
const fetch = (...args) => import('node-fetch').then(({default: fetch}) => fetch(...args));
```
## Exercution
```
npm install
npm start
**or**
npm dev
```
## Test Results
```
îș§ npm start
~/boilerplate-project-stockchecker$ npm run start
> boilerplate-project-stockchecker@0.0.1 start /home/runner/boilerplate-project-stockchecker
> node server.js
Your app is listening on port 1234
Running Tests...
MongoDB Connected đ
Functional Tests
GET /api/stock-prices/
https://stock-price-checker-proxy.freecodecamp.rocks/v1/stock/tsla/quote
Found Stock: {
_id: new ObjectId("629e6731622a2807b6e50ddf"),
symbol: 'TSLA',
likes: [],
__v: 0
}
Stock Data: TSLA 714.95
â 1 stock (528ms)
{ stock: 'TSLA', price: 714.95, likes: 0 }
https://stock-price-checker-proxy.freecodecamp.rocks/v1/stock/nvda/quote
Found Stock: {
_id: new ObjectId("629e6732622a2807b6e50de2"),
symbol: 'NVDA',
likes: [ '::ffff:127.0.0.1' ],
__v: 0
}
Stock Data: NVDA 187.81
â 1 stock with like (295ms)
https://stock-price-checker-proxy.freecodecamp.rocks/v1/stock/goog/quote
Found Stock: {
_id: new ObjectId("629e6733622a2807b6e50de5"),
symbol: 'GOOG',
likes: [ '::ffff:127.0.0.1' ],
__v: 0
}
Stock Data: GOOG 2338.64
â 1 stock with like again (ensure likes arent double counted) (331ms)
https://stock-price-checker-proxy.freecodecamp.rocks/v1/stock/tsla/quote
https://stock-price-checker-proxy.freecodecamp.rocks/v1/stock/nvda/quote
Found Stock: {
_id: new ObjectId("629e6733622a2807b6e50de8"),
symbol: 'tsla',
likes: [],
__v: 0
}
Found Stock: {
_id: new ObjectId("629e6733622a2807b6e50deb"),
symbol: 'nvda',
likes: [],
__v: 0
}
â 2 stocks (795ms)
https://stock-price-checker-proxy.freecodecamp.rocks/v1/stock/tsla/quote
https://stock-price-checker-proxy.freecodecamp.rocks/v1/stock/nvda/quote
Found Stock: {
_id: new ObjectId("629e6733622a2807b6e50de8"),
symbol: 'tsla',
likes: [],
__v: 0
}
Found Stock: {
_id: new ObjectId("629e6733622a2807b6e50deb"),
symbol: 'nvda',
likes: [],
__v: 0
}
â 2 stocks and liking them (498ms)
5 passing (2s)
```
**FCC tests**

**MongoDB Data**
