-
Notifications
You must be signed in to change notification settings - Fork 2
/
index.js
68 lines (62 loc) · 2.16 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
'use strict';
require('babel-core/register')({});
require('babel-polyfill');
const server = require('./server/server').default;
const loadcsv = require('./utility/csvtojson.js');
const db = require('./server/db/db-model.js');
const stockData = require('./setup/stockData/stockData.js');
const request = require('request');
const PORT = process.env.PORT || 3000;
// loadcsv.loadCSV('setup/Companies3.csv')
// .then((data) => {
// for(var i =0; i<data.length; i++) {
// db.saveKeyword(data[i]).then((node)=> {console.log('done!');}).catch((err)=> {console.log(err);});
// }
// })
// .catch(() => {
// console.log('failed to parse data');
// }).then(function (){
// console.log("done all!");
// });
// let SPX = stockData.SPX;
// let etfData = [];
// SPX.forEach((symbol) => {
// console.log('hey hey');
// var promise = new Promise((resolve, reject) => {
// console.log('promise in');
// console.log(symbol);
// request.get('https://www.quandl.com/api/v3/datasets/WIKI/' + symbol.Symbol + '/data.json?column_index=4&api_key=fiuzUjysoMY6y1FMEbBE&start_date=2014-02-28&end_date=2016-01-31&order=asc&collapse=monthly',
// (err, response, body) => {
// console.log('request response');
// console.log("body type:", typeof body);
// var parsedBody = JSON.parse(body);
// if (err) {
// reject(err);
// } else {
// let returnObj = {};
// returnObj.data = parsedBody['dataset_data'].data.map((closingPrice) => {
// return closingPrice[1];
// });
// returnObj.Stock = symbol.Symbol;
// returnObj.Sector = symbol.Sector;
// returnObj.Name = symbol.Name;
// resolve(returnObj);
// }
// });
// });
// etfData.push(promise);
// });
// Promise.all(etfData).then((results) => {
// results.forEach((stock) => {
// stock.data = JSON.stringify(stock.data);
// db.saveStock( stock ).then((node) => {
// console.log('done!');
// })
// .catch((err) => {
// console.log(err);
// });
// });
// });
server.listen(PORT, () => {
console.log(`Server established on port ${PORT}.`);
});