forked from psi-4ward/psitransfer
-
Notifications
You must be signed in to change notification settings - Fork 0
/
config.js
75 lines (70 loc) · 2.36 KB
/
config.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';
const path = require('path');
const fsp = require('fs-promise');
// Default Config
// Do not edit this, generate a config.<ENV>.js for your NODE_ENV
// or use ENV-VARS like PSITRANSFER_PORT=8000
const config = {
"uploadDir": path.resolve(__dirname + '/data'),
"iface": '0.0.0.0',
// set to false to disable HTTP
"port": 3000,
// HTTPS, set all 3 values to enable
"sslPort": 8443,
"sslKeyFile": false,
"sslCertFile": false,
// Force redirect to https
// can be true or a specific url like https://example.com:8443
// keep empty to disable
"forceHttps": '',
// retention options in seconds:label
"retentions": {
"one-time": "one time download",
"3600": "1 Hour",
"21600": "6 Hours",
"86400": "1 Day",
"259200": "3 Days",
"604800": "1 Week",
"1209600": "2 Weeks",
"2419200": "4 Weeks",
"4838400": "8 Weeks"
},
// admin password, set to false to disable /admin page
"adminPass": false,
"defaultRetention": "604800",
// expire every file after maxAge (eg never downloaded one-time files)
"maxAge": 3600*24*75, // 75 days
// maximum file-size for previews in byte
"maxPreviewSize": Math.pow(2,20) * 2, // 2MB
"mailTemplate": 'mailto:?subject=File Transfer&body=You can download the files here: %%URL%%',
// see https://github.com/expressjs/morgan
// set to false to disable logging
"accessLog": ':date[iso] :method :url :status :response-time :remote-addr',
// use to set custom upload url
"uploadAppPath": '/',
// event webhooks
// invokes an HTTP POST to a url whenever a file is downloaded
// for more info, see the webhooks section of docs/configuration.md
"fileDownloadedWebhook": null,
"fileUploadedWebhook": null
};
// Load NODE_ENV specific config
const envConfFile = path.resolve(__dirname, `config.${process.env.NODE_ENV}.js`);
if(process.env.NODE_ENV && fsp.existsSync(envConfFile)) {
Object.assign(config, require(envConfFile));
}
// Load config from ENV VARS
let envName;
for (let k in config) {
envName = 'PSITRANSFER_'+ k.replace(/([A-Z])/g, $1 => "_" + $1).toUpperCase();
if(process.env[envName]) {
if(typeof config[k] === 'number') {
config[k] = parseInt(process.env[envName], 10);
} else if (typeof config[k] === 'object') {
config[k] = JSON.parse(process.env[envName]);
} else {
config[k] = process.env[envName];
}
}
}
module.exports = config;