-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.js
33 lines (26 loc) · 918 Bytes
/
app.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
var express = require("express"),
app = express(),
mongoose = require("mongoose"),
config = require("./config"),
bodyParser = require("body-parser"),
stockController = require("./controllers/stockController"),
cors = require("cors");
var port = process.env.PORT || 3000;
var corsOptions = {
origin: function (origin, callback) {
var originIsWhitelisted = (origin ? origin.includes(process.env.allowedOrigin) : false);
callback(true ? null : 'Bad Request', originIsWhitelisted);
}
}
app.use(cors(corsOptions));
app.use(bodyParser.json());
mongoose.connect(config.getDbConnectionString());
stockController.buyStock(app);
stockController.buyStocks(app);
stockController.updateStock(app);
stockController.getStocks(app);
stockController.sellStock(app);
stockController.addDividend(app);
stockController.deleteStock(app);
stockController.estimateStockPrice(app);
app.listen(port);