Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix-16 #24

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion app.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
5 changes: 0 additions & 5 deletions config/config.env.example

This file was deleted.

5 changes: 5 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
"lodash": "^4.17.19",
"method-override": "^3.0.0",
"mongoose": "^5.9.25",
"mongoose-float": "^1.0.4",
"morgan": "^1.10.0",
"npm": "^6.14.7",
"passport": "^0.4.1",
Expand Down
67 changes: 67 additions & 0 deletions routes/api/view.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
// View Routes
//jshint esversion:8
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bad option value.

const express = require("express");
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

'const' is available in ES6 (use 'esversion: 6') or Mozilla JS extensions (use moz).

const router = express.Router();
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

'const' is available in ES6 (use 'esversion: 6') or Mozilla JS extensions (use moz).

const alpha = require("alphavantage")({
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

'const' is available in ES6 (use 'esversion: 6') or Mozilla JS extensions (use moz).

key: process.env.ALPHA_VANTAGE_KEY
});

const getOverview = require("../../helpers/getOverview");
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

'const' is available in ES6 (use 'esversion: 6') or Mozilla JS extensions (use moz).

const {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

'const' is available in ES6 (use 'esversion: 6') or Mozilla JS extensions (use moz).
'destructuring binding' is available in ES6 (use 'esversion: 6') or Mozilla JS extensions (use moz).

ensureAuth
} = require("../../middleware/auth");

// @desc View Page
// @route GET /view/:symbol
// @access Private
router.get("/:symbol", ensureAuth, async (req, res) => {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Expected '(' and instead saw '{'.

const symbol = req.params.symbol;
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

'arrow function syntax (=>)' is only available in ES6 (use 'esversion: 6').
Expected ')' and instead saw 'req'.
Expected ')' to match '{' from line 17 and instead saw 'symbol'.
Expected an assignment or function call and instead saw an expression.
Expected an identifier and instead saw '='.
Expected an identifier and instead saw 'const' (a reserved word).

let data = await getOverview(symbol);
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

'let' is available in ES6 (use 'esversion: 6') or Mozilla JS extensions (use moz).
Missing semicolon.


alpha.data
.intraday(symbol)
.then((data) => {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

'arrow function syntax (=>)' is only available in ES6 (use 'esversion: 6').

const intraDay = data["Time Series (1min)"];
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

'const' is available in ES6 (use 'esversion: 6') or Mozilla JS extensions (use moz).

let dates = [];
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

'let' is available in ES6 (use 'esversion: 6') or Mozilla JS extensions (use moz).

let opening = [];
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

'let' is available in ES6 (use 'esversion: 6') or Mozilla JS extensions (use moz).

let closing = [];
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

'let' is available in ES6 (use 'esversion: 6') or Mozilla JS extensions (use moz).

let highs = [];
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

'let' is available in ES6 (use 'esversion: 6') or Mozilla JS extensions (use moz).

let lows = [];
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

'let' is available in ES6 (use 'esversion: 6') or Mozilla JS extensions (use moz).

let volumes = [];
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

'let' is available in ES6 (use 'esversion: 6') or Mozilla JS extensions (use moz).

const keys = Object.getOwnPropertyNames(intraDay);
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

'const' is available in ES6 (use 'esversion: 6') or Mozilla JS extensions (use moz).


for (let i = 0; i < 100; i++) {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

'let' is available in ES6 (use 'esversion: 6') or Mozilla JS extensions (use moz).

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", {
data,
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

'object short notation' is available in ES6 (use 'esversion: 6') or Mozilla JS extensions (use moz).

dates,
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

'object short notation' is available in ES6 (use 'esversion: 6') or Mozilla JS extensions (use moz).

opening,
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

'object short notation' is available in ES6 (use 'esversion: 6') or Mozilla JS extensions (use moz).

closing,
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

'object short notation' is available in ES6 (use 'esversion: 6') or Mozilla JS extensions (use moz).

highs,
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

'object short notation' is available in ES6 (use 'esversion: 6') or Mozilla JS extensions (use moz).

lows,
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

'object short notation' is available in ES6 (use 'esversion: 6') or Mozilla JS extensions (use moz).

volumes
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

'object short notation' is available in ES6 (use 'esversion: 6') or Mozilla JS extensions (use moz).

}
);
})
.catch((err) => {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

'arrow function syntax (=>)' is only available in ES6 (use 'esversion: 6').

// Handle the error
console.log(err);
});
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unrecoverable syntax error. (95% scanned).

});

module.exports = router;
85 changes: 85 additions & 0 deletions views/view.ejs
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
<!DOCTYPE html>
<html lang="en">

<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>WeatherApp</title>
<script src="/main.js"></script>
<link href="https://unpkg.com/tailwindcss@^1.0/dist/tailwind.min.css" rel="stylesheet">
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/Chart.min.js"></script>
<style>
@media (min-width:320px){
#chart{
width: 800px;
height: 900px;
}
}
</style>
</head>

<body>
<form action="/" method="POST" class="flex flex-col sm:flex-row justify-center">
<label for="cityInput" class="mt-2 px-3 py-2">stockName: </label>
<input type="text" name="stockName" id="stockInput"
class="mt-2 px-3 py-2 shadow border rounded-lg w-4/6 px-3 py-2 text-gray-700 focus:bg-blue-100
placeholder-indigo-300">
<button type="submit"
class="m-4 bg-indigo-200 border-b-4 border-t-4 border-indigo-800 px-4 py-1 mt-2 px-3 py-2">Search</button>
</form>


<canvas id="chart"></canvas>

<%for(var i=0; i<=5; i++){%>
<table class="table-auto border-2 border-gray-600 ">
<thead>
<tr>
<th class="px-4 py-2">Date</th>
<th class="px-4 py-2">opening</th>
<th class="px-4 py-2">closing</th>
<th class="px-4 py-2">highs</th>
<th class="px-4 py-2">lows</th>
<th class="px-4 py-2">volumes</th>
</tr>
</thead>
<tbody>
<tr>
<td class="border-b-2 px-4 py-2 "><%- dates[i] %></td>
<td class="border-b-2 px-4 py-2"><%- opening[i] %></td>
<td class="border-b-2 px-4 py-2"><%- closing[i] %></td>
<td class="border-b-2 px-4 py-2"><%- highs[i] %></td>
<td class="border-b-2 px-4 py-2"><%- lows[i] %></td>
<td class="border-b-2 px-4 py-2"><%- volumes[i] %></td>
</tr>
</tbody>
</table>

<%}%>

<script>
var datesList = <%- JSON.stringify(dates) %>;
var closingList = <%- JSON.stringify(closing) %> ;
var ctx = document.getElementById('chart').getContext('2d');
var myChart = new Chart(ctx, {
type: 'line',
data: {
labels: datesList,closingList,
datasets: [{
label: "Microsoft's Closing Stock Values",
data: closingList,
borderColor: "#3e95cd",
backgroundColor: "rgba(118,152,255,0.4)"
}]
},
options: {
responsive:true,
maintainAspectRatio: true,
},
});
</script>


</body>

</html>