-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathapp.js
104 lines (75 loc) · 3.33 KB
/
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
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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
// /**
// * Module dependencies.
// */
var express = require('express'),
bodyParser = require('body-parser'),
drataRepository = require('./repositories/drataRepository'),
controller = require('./routes/externaldatacontroller'),
http = require('http'),
path = require('path'),
config = require('./routes/config.json'),
skt = require('./routes/socket'),
logger = require('./routes/logger');
var app = express();
var serverNames = config.dataSources.map(function(d){
return d.alias;
});
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({ extended: true}));
app.use(express.static(path.join(__dirname, 'content')));
app.set('port',process.env.PORT || 3000);
app.get('/dashboard/:dashboardId', function(req, res) {
logger.logRequest(req, { pageId: 'dashboard'});
res.sendFile('/dash.html', { root: __dirname });
});
app.get('/dashboard', function(req, res) {
logger.logRequest(req, { pageId: 'dashboard manager'});
res.sendFile('/dash.html', { root: __dirname });
});
app.get('/', function(req, res) {
logger.logRequest(req, { pageId: 'homepage'});
res.sendFile('homepage.html', { root: __dirname });
});
app.get('/api/databasepop', controller.databasepop);
//get dashboard
app.get('/api/dashboard/:dashboardId', drataRepository.findDashboard);
//get dashboard
app.get('/api/widget/:widgetId', drataRepository.findWidget);
//get widgets of dashboard
app.get('/api/dashboard/:dashboardId/widgets', drataRepository.findWidgetsOfDashboard);
app.delete('/api/dashboard/:dashboardId/widgets', drataRepository.deleteAllWidgetsDashboard);
//find all dashboards. dont include widgets
app.get('/api/dashboards', drataRepository.getAllDashboards);
app.get('/api/truncatedata', drataRepository.truncateData);
app.get('/api/generateDemoDashboard', drataRepository.generateDemoDashboard);
app.post('/api/widgets', drataRepository.getWidgets);
//update dashboard
app.put('/api/dashboard', drataRepository.updateDashboard);
//add dashboard
app.post('/api/dashboard', drataRepository.addDashboard);
//delete dashboard
app.delete('/api/dashboard/:dashboardId', drataRepository.deleteDashboard);
//update widget
app.put('/api/widget', drataRepository.updateWidget);
app.put('/api/widgetviewoptions', drataRepository.updateWidgetViewOptions);
//create widget
app.post('/api/widget', drataRepository.addWidget);
//delete widget
app.delete('/api/widget/:widgetId', drataRepository.deleteWidget);
app.get('/api/tags', drataRepository.getAllTags);
app.get('/api/dashboard/:dashboardId/tags', drataRepository.getAllTagsOfDashboard);
app.delete('/api/dashboard/:dashboardId/tags', drataRepository.deleteAllTagsDashboard);
app.put('/api/tags', drataRepository.addTag);
app.delete('/api/tags/:tagId', drataRepository.removeTag);
app.get('/api/external/datasource', function(req, res){
res.json(serverNames);
});
app.get('/api/external/:datasource/database', controller.getDatabaseNames);
app.get('/api/external/:datasource/:dbname/collectionNames', controller.getCollectionNames);
app.get('/api/external/:datasource/:dbname/:collectionName/properties', controller.findProperties);
app.post('/api/external/:datasource/:dbname/:collectionName', controller.findCollection);
var server = http.createServer(app);
server.listen(app.get('port'), function(){
console.log('Express server listening on port ' + app.get('port'));
});
skt.initialize(server);