-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.js
104 lines (84 loc) · 2.97 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
104
//jshint esversion:6
const express = require("express");
const bodyParser = require("body-parser");
const socketio = require('socket.io');
const MongoStore = require('connect-mongo');
const mongoose = require("mongoose");
const http = require("http");
const session = require('express-session');
const path = require('path');
const { MONGO_URL, PORT} = require("./config/config");
// Database connection -----------------------------------------------------------------------------
mongoose.set('strictQuery', false);
try {
mongoose.connect(MONGO_URL + "UIDB");
} catch (error) {
console.log(error);
}
// Routes imports ----------------------------------------------------------------------------------
const homeRoute = require('./routes/homeRoute');
const registerRoute = require('./routes/registerRoute');
const logoutRoute = require('./routes/logoutRoute');
const dashboardRoute = require('./routes/dashboardRoute');
const datasetsRoute = require('./routes/datasetsRoute');
const pipelinesRoute = require('./routes/pipelinesRoute');
const functionsRoute = require('./routes/functionsRoute');
const modelsRoute = require('./routes/modelsRoute');
const visualizationRoute = require('./routes/visualizationRoute');
const messagesRoute = require('./routes/messagesRoute');
const route404 = require('./routes/404Route');
const githubAuth = require('./routes/githubAuth');
const getFileRoute = require('./routes/getFileRoute');
// -------------------------------------------------------------------------------------------------
const app = express();
const server = http.createServer(app);
const io = socketio(server);
// Middleware ----------------------------------
app.set('view engine', 'ejs');
app.use(bodyParser.urlencoded({extended:true}));
app.use(bodyParser.json());
app.use(express.static("public"));
app.use('/vis',express.static(path.join(__dirname, 'public/downloads/vis')));
app.use(session({
secret:'diastema',
resave:false,
saveUninitialized:false,
store:MongoStore.create({
mongoUrl: MONGO_URL+"UIDB",
collection:'sessions'
})
}));
// Make io accessible to our routers
app.use(function(req,res,next){
req.io = io;
next();
});
// Home route -----------
app.use(homeRoute);
// Register route -------
app.use(registerRoute);
// Logout route ---------
app.use(logoutRoute);
// Dashboard route ------
app.use(dashboardRoute);
// Datasets route -------
app.use(datasetsRoute);
// Pipelines route ------
app.use(pipelinesRoute);
// Functions route ------
app.use(functionsRoute);
// Models route ---------
app.use(modelsRoute)
// Visualization route --
app.use(visualizationRoute);
// Get file route -------
app.use(getFileRoute);
// Messaging route ------
app.use(messagesRoute);
// 404 route ------------
app.use(route404);
// Github OAuth route ---
app.use(githubAuth);
server.listen(PORT, function () {
console.log('[INFO] Started on port 5400');
});