-
Notifications
You must be signed in to change notification settings - Fork 21
/
index.js
75 lines (67 loc) · 2.24 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
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
'use strict';
/**
* A simple express server to expose unifile api
* https://github.com/silexlabs/unifile/
* license: GPL v2
*/
const Os = require('os');
const express = require('express');
const cookieParser = require('cookie-parser');
const session = require('express-session');
const Router = require('./router.js');
// 6805 is the date of sexual revolution started in paris france 8-)
const DEFAULT_PORT = 6805;
const port = process.env.PORT || DEFAULT_PORT;
const rootPath = process.env.SERVER_PATH || '';
const rootUrl = process.env.SERVER_URL || `http://localhost:${port}${rootPath}`;
const app = express();
app.use(express.json());
app.use(cookieParser());
app.use(session({
resave: false,
saveUninitialized: false,
secret: 'test session secret'
}));
const router = new Router({
rootUrl,
rootPath,
dropbox: {
clientId: process.env.DROPBOX_APP_ID || '8lxz0i3aeztt0im',
clientSecret: process.env.DROBOX_APP_SECRET || 'twhvu6ztqnefkh6',
redirectUri: process.env.DROPBOX_APP_REDIRECT || `${rootUrl}/ce/dropbox/oauth_callback`,
state: 'aaathub'
},
fs: {
sandbox: Os.homedir(),
showHiddenFile: false
},
ftp: process.env.ENABLE_FTP !== 'false' ? {redirectUri: `${rootUrl}/ce/ftp/signin`} : undefined,
sftp: process.env.ENABLE_SFTP !== 'false' ? {redirectUri: `${rootUrl}/ce/ftp/signin`} : undefined,
github: {
clientId: process.env.GITHUB_APP_ID || 'f124e4148bf9d633d58b',
clientSecret: process.env.GITHUB_APP_SECRET || '1a8fcb93d5d0786eb0a16d81e8c118ce03eefece',
redirectUri: process.env.GITHUB_APP_REDIRECT || `${rootUrl}/ce/github/oauth_callback`,
state: 'aaathub'
},
thumbnails: {
width: 256,
height: 256,
extensions: [
'jpg',
'jpeg',
'png',
'svg'
], // Unsupported extensions will be replaced with an icon
},
unsplash: {
accessKey: process.env.UNSPLASH_ACCESS_KEY || '4bce6009ffa07149e179d7928bbf28cd15760e5393d17b172624945f935fef58',
appName: process.env.UNSPLASH_APP_NAME || 'Silex V2',
offlineTestPath: process.env.UNSPLASH_OFFLINE_TEST_PATH,
},
hyperdrive: !!process.env.ENABLE_HYPERDRIVE,
});
app.use(rootPath + '/ce', router);
// Server 'loop'
app.listen(port, () => {
console.log(`Serving cloud explorer on ${rootUrl}/ce/cloud-explorer/`);
});