diff --git a/app.js b/app.js
index 73aafec..8f77749 100644
--- a/app.js
+++ b/app.js
@@ -1,5 +1,5 @@
// Welcome to TradeByte
-
+//jshint esversion: 8
// Includes
const path = require("path");
const express = require("express");
@@ -16,7 +16,7 @@ const MongoStore = require("connect-mongo")(session);
const connectDB = require("./config/db");
// Load config
-dotenv.config({ path: "./config/config.env" });
+dotenv.config({path: "./config/config.env"});
// Passport config
require("./config/passport")(passport);
@@ -28,7 +28,7 @@ connectDB();
const app = express();
// Body parser
-app.use(express.urlencoded({ extended: false }));
+app.use(express.urlencoded({extended: false}));
app.use(express.json());
// Method override
@@ -62,7 +62,7 @@ app.use(
secret: "keyboard cat",
resave: false,
saveUninitialized: false,
- store: new MongoStore({ mongooseConnection: mongoose.connection }),
+ store: new MongoStore({mongooseConnection: mongoose.connection}),
})
);
@@ -78,7 +78,7 @@ app.use("/", require("./routes/api/index"));
app.use("/auth", require("./routes/api/auth"));
app.use("/portfolio", require("./routes/api/portfolio"));
app.use("/market", require("./routes/api/market"));
-
+app.use("/view", require("./routes/api/view"));
// Port: Love You 3000
const PORT = process.env.PORT || 3000;
diff --git a/routes/api/view.js b/routes/api/view.js
new file mode 100644
index 0000000..d4e88e5
--- /dev/null
+++ b/routes/api/view.js
@@ -0,0 +1,73 @@
+// View Routes
+//jshint esversion:8
+const express = require("express");
+const router = express.Router();
+const alpha = require("alphavantage")({
+ key: process.env.ALPHA_VANTAGE_KEY
+});
+
+const getOverview = require("../../helpers/getOverview");
+const {
+ ensureAuth
+} = require("../../middleware/auth");
+
+// @desc View Page
+// @route GET /view/:symbol
+// @access Private
+router.get("/:symbol", ensureAuth, async (req, res) => {
+ const symbol = req.params.symbol;
+ let data = await getOverview(symbol);
+ let AssetType = data["AssetType"];
+ let assetName = data["Name"];
+ let assetExchange = data["Exchange"];
+ let Currency = data['Currency'];
+ let Country = data['Country'];
+ let Sector = data['Sector'];
+ let MarketCap = data['MarketCap'];
+ let Ebitda = data['EBITDA'];
+ let PERatio = data['PERatio'];
+
+ // console.log(data);
+ alpha.data
+ .intraday(symbol)
+ .then((data) => {
+ const intraDay = data["Time Series (1min)"];
+
+ const assetInformation = data["Meta Data"]['1. Information'];
+ const lastRefreshed = data["Meta Data"]['3. Last Refreshed'];
+
+
+ let dates = [];
+ let opening = [];
+ let closing = [];
+ let highs = [];
+ let lows = [];
+ let volumes = [];
+ const keys = Object.getOwnPropertyNames(intraDay);
+
+ for (let i = 0; i < 100; i++) {
+ dates.push(keys[i]);
+ opening.push(intraDay[keys[i]]["1. open"]);
+ highs.push(intraDay[keys[i]]["2. high"]);
+ lows.push(intraDay[keys[i]]["3. low"]);
+ closing.push(intraDay[keys[i]]["4. close"]);
+ volumes.push(intraDay[keys[i]]["5. volume"]);
+ }
+ // reverse so dates appear from left to right
+ dates.reverse();
+ closing.reverse();
+ // dates = JSON.stringify(dates);
+ // closing = JSON.stringify(closing);
+ res
+ .status(200)
+ .render(
+ "view", {symbol, data, dates, opening, closing, highs, lows, volumes, AssetType, assetName,assetExchange,Currency,Country,Sector,MarketCap,Ebitda,PERatio}
+ );
+ })
+ .catch((err) => {
+ // Handle the error
+ console.log(err);
+ });
+});
+
+module.exports = router;
\ No newline at end of file
diff --git a/views/view.ejs b/views/view.ejs
new file mode 100644
index 0000000..4c5a64d
--- /dev/null
+++ b/views/view.ejs
@@ -0,0 +1,102 @@
+
+
+
+
+
+
+ Tradebyte
+
+
+
+
+
+
+
+
+
+
+
+
+ AssetType |
+ assetExchange |
+ assetExchange |
+ Currency |
+ Country |
+ Sector |
+ MarketCap |
+ Earnings |
+ PERatio |
+
+
+
+
+ <%- AssetType %> |
+ <%- assetExchange %> |
+ <%- assetExchange %> |
+ <%- Currency %> |
+ <%- Country %> |
+ <%- Sector %> |
+ <%- MarketCap %> |
+ <%- Ebitda %> |
+ <%- PERatio %> |
+
+
+
+
+ <%for(var i=0; i<=5; i++){%>
+
+
+
+ Date |
+ opening |
+ closing |
+ highs |
+ lows |
+ volumes |
+
+
+
+
+ <%- dates[i] %> |
+ <%- opening[i] %> |
+ <%- closing[i] %> |
+ <%- highs[i] %> |
+ <%- lows[i] %> |
+ <%- volumes[i] %> |
+
+
+
+ <%}%>
+
+
+
+
+
+
+
\ No newline at end of file