Add env-var json support
e.g.: PSITRANSFER_RETENTIONS='{"one-time":"one time download","604800":"1 Week"}'
This commit is contained in:
@@ -1,19 +1,17 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
accessLog: 'dev',
|
"accessLog": 'dev',
|
||||||
retentions: {
|
"retentions": {
|
||||||
"one-time": "one time download",
|
"one-time": "one time download",
|
||||||
10: "10 Seconds",
|
"60": "1 Minute",
|
||||||
60: "1 Minute",
|
"300": "5 Minutes",
|
||||||
300: "5 Minutes",
|
"3600": "1 Hour",
|
||||||
3600: "1 Hour",
|
"21600": "6 Hours",
|
||||||
21600: "6 Hours",
|
"86400": "1 Day",
|
||||||
86400: "1 Day",
|
"259200": "3 Days",
|
||||||
259200: "3 Days",
|
"604800": "1 Week",
|
||||||
604800: "1 Week",
|
"1209600": "2 Weeks"
|
||||||
1209600: "2 Weeks",
|
|
||||||
2419200: "4 Weeks",
|
|
||||||
4838400: "8 Weeks"
|
|
||||||
},
|
},
|
||||||
|
"defaultRetention": 3600
|
||||||
};
|
};
|
||||||
|
|||||||
34
config.js
34
config.js
@@ -6,28 +6,28 @@ const fsp = require('fs-promise');
|
|||||||
// Do not edit this, generate a config.<ENV>.js for your NODE_ENV
|
// Do not edit this, generate a config.<ENV>.js for your NODE_ENV
|
||||||
// or use ENV-VARS like PSITRANSFER_PORT=8000
|
// or use ENV-VARS like PSITRANSFER_PORT=8000
|
||||||
const config = {
|
const config = {
|
||||||
uploadDir: path.resolve(__dirname + '/data'),
|
"uploadDir": path.resolve(__dirname + '/data'),
|
||||||
port: 3000,
|
"port": 3000,
|
||||||
iface: '0.0.0.0',
|
"iface": '0.0.0.0',
|
||||||
// retention options in seconds:label; first one is the default
|
// retention options in seconds:label
|
||||||
retentions: {
|
retentions: {
|
||||||
"one-time": "one time download",
|
"one-time": "one time download",
|
||||||
3600: "1 Hour",
|
"3600": "1 Hour",
|
||||||
21600: "6 Hours",
|
"21600": "6 Hours",
|
||||||
86400: "1 Day",
|
"86400": "1 Day",
|
||||||
259200: "3 Days",
|
"259200": "3 Days",
|
||||||
604800: "1 Week",
|
"604800": "1 Week",
|
||||||
1209600: "2 Weeks",
|
"1209600": "2 Weeks",
|
||||||
2419200: "4 Weeks",
|
"2419200": "4 Weeks",
|
||||||
4838400: "8 Weeks"
|
"4838400": "8 Weeks"
|
||||||
},
|
},
|
||||||
defaultRetention: 604800,
|
"defaultRetention": 604800,
|
||||||
// maximum file-size for previews in byte
|
// maximum file-size for previews in byte
|
||||||
maxPreviewSize: Math.pow(2,20) * 2, // 2MB
|
"maxPreviewSize": Math.pow(2,20) * 2, // 2MB
|
||||||
mailTemplate: 'mailto:?subject=File Transfer&body=You can download the files here: %%URL%%',
|
"mailTemplate": 'mailto:?subject=File Transfer&body=You can download the files here: %%URL%%',
|
||||||
// see https://github.com/expressjs/morgan
|
// see https://github.com/expressjs/morgan
|
||||||
// set to false to disable logging
|
// set to false to disable logging
|
||||||
accessLog: ':date[iso] :method :url :status :response-time :remote-addr'
|
"accessLog": ':date[iso] :method :url :status :response-time :remote-addr'
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@@ -44,6 +44,8 @@ for (let k in config) {
|
|||||||
if(process.env[envName]) {
|
if(process.env[envName]) {
|
||||||
if(typeof config[k] === 'number') {
|
if(typeof config[k] === 'number') {
|
||||||
config[k] = parseInt(process.env[envName], 10);
|
config[k] = parseInt(process.env[envName], 10);
|
||||||
|
} else if (typeof config[k] === 'object') {
|
||||||
|
config[k] = JSON.parse(process.env[envName]);
|
||||||
} else {
|
} else {
|
||||||
config[k] = process.env[envName];
|
config[k] = process.env[envName];
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user