-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
40 lines (34 loc) · 1.03 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
// Injecting environment variables
require('dotenv').config();
var path = require('path');
var express = require('express');
var cors = require('cors');
var compression = require('compression');
var serveStatic = require('serve-static');
var passport = require('passport');
var DBS = require('./dbs');
const PORT = process.env.PORT || 8003;
const app = express();
app.use(compression());
app.use(cors());
// Define routes
app.use(require('./routes'));
// Serve tilesets
global.dataRoot = path.join(__dirname, 'data');
app.use(serveStatic(path.join(__dirname, 'data'), {
index: false
}));
/*
* Firstly we connect to a MongoDB server,
* Then we start listening for incoming requests
*/
DBS.EstablishConnection()
.then(function () {
console.log("MongoDB connection established!");
const server = app.listen(PORT, function () {
console.log('3D backend is running on http://localhost:' + PORT);
});
})
.catch(function (error) {
console.log("Database connection failure: " + error.err);
});