-
Notifications
You must be signed in to change notification settings - Fork 2
/
server.js
64 lines (39 loc) · 2.07 KB
/
server.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
const express = require('express');
const http = require('http')
const path = require('path');
var fs = require('fs');
var getClientConfig = function () {
var result = {};
if(!process.env.BROWSEAPI_URI) throw new Error("undefined in environment: BROWSEAPI_URI");
if(!process.env.ONEDRIVE_CLIENTID) throw new Error("undefined in environment: ONEDRIVE_CLIENTID");
if(!process.env.ONEDRIVE_REDIRECTURI) throw new Error("undefined in environment: ONEDRIVE_REDIRECTURI");
if(!process.env.ONEDRIVE_SCOPES) throw new Error("undefined in environment: ONEDRIVE_SCOPES");
if(!process.env.ONEDRIVE_AUTHSERVICEURI) throw new Error("undefined in environment: ONEDRIVE_AUTHSERVICEURI");
if(!process.env.AUTH0_DOMAIN) throw new Error("undefined in environment: AUTH0_DOMAIN");
if(!process.env.AUTH0_CLIENTID) throw new Error("undefined in environment: AUTH0_CLIENTID");
if(!process.env.AUTH0_REDIRECT_URI) throw new Error("undefined in environment: AUTH0_REDIRECT_URI");
if(!process.env.DEFAULT_COLUMN) process.env.DEFAULT_COLUMN = '';
result.BROWSEAPI_URI = process.env.BROWSEAPI_URI;
result.ONEDRIVE_CLIENTID = process.env.ONEDRIVE_CLIENTID;
result.ONEDRIVE_REDIRECTURI = process.env.ONEDRIVE_REDIRECTURI;
result.ONEDRIVE_SCOPES = process.env.ONEDRIVE_SCOPES;
result.ONEDRIVE_AUTHSERVICEURI = process.env.ONEDRIVE_AUTHSERVICEURI;
result.AUTH0_DOMAIN = process.env.AUTH0_DOMAIN;
result.AUTH0_CLIENTID = process.env.AUTH0_CLIENTID;
result.AUTH0_REDIRECT_URI = process.env.AUTH0_REDIRECT_URI;
result.DEFAULT_COLUMN = process.env.DEFAULT_COLUMN;
return result;
}
var writeClientConfig = function(config){
fs.writeFileSync('./configDetailsConstant.js',`var CONFIG = ${JSON.stringify(config)}`);
}
writeClientConfig(getClientConfig());
const app = express();
app.use(express.static(path.join(__dirname, '')));
app.get('/*', (req, res) => {
res.sendFile(path.join(__dirname + '/index.html'));
});
const port = process.env.PORT || 8080;
app.set('port', port);
const server = http.createServer(app);
server.listen(port, () => console.log(`running on port ${port}`));