-
Notifications
You must be signed in to change notification settings - Fork 11
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
Fix-16 #24
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
// View Routes | ||
//jshint esversion:8 | ||
const express = require("express"); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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")({ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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"); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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). |
||
ensureAuth | ||
} = require("../../middleware/auth"); | ||
|
||
// @desc View Page | ||
// @route GET /view/:symbol | ||
// @access Private | ||
router.get("/:symbol", ensureAuth, async (req, res) => { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Expected '(' and instead saw '{'. |
||
const symbol = req.params.symbol; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 'arrow function syntax (=>)' is only available in ES6 (use 'esversion: 6'). |
||
let data = await getOverview(symbol); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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). |
||
|
||
alpha.data | ||
.intraday(symbol) | ||
.then((data) => { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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)"]; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 = []; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 = []; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 = []; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 = []; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 = []; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 = []; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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++) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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) => { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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); | ||
}); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Unrecoverable syntax error. (95% scanned). |
||
}); | ||
|
||
module.exports = router; |
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> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Bad option value.