mirror of
https://github.com/YunoHost-Apps/psitransfer_ynh.git
synced 2024-09-03 20:16:06 +02:00
Update config.js
This commit is contained in:
parent
9e43d34da8
commit
bd0d7e66cf
1 changed files with 52 additions and 8 deletions
|
@ -1,20 +1,64 @@
|
|||
'use strict';
|
||||
const path = require('path');
|
||||
const fsp = require('fs-promise');
|
||||
|
||||
module.exports = {
|
||||
"accessLog": 'dev',
|
||||
// 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": __PORT__,
|
||||
// HTTPS, set all 3 values to enable
|
||||
"sslPort": 8443,
|
||||
"sslKeyFile": false,
|
||||
"sslCertFile": false,
|
||||
// retention options in seconds:label
|
||||
"retentions": {
|
||||
"one-time": "one time download",
|
||||
"60": "1 Minute",
|
||||
"300": "5 Minutes",
|
||||
"3600": "1 Hour",
|
||||
"21600": "6 Hours",
|
||||
"86400": "1 Day",
|
||||
"259200": "3 Days",
|
||||
"604800": "1 Week",
|
||||
"1209600": "2 Weeks"
|
||||
"1209600": "2 Weeks",
|
||||
"2419200": "4 Weeks",
|
||||
"4838400": "8 Weeks"
|
||||
},
|
||||
"defaultRetention": 3600,
|
||||
|
||||
"adminPass": "__ADMINPASS__"
|
||||
// "sslKeyFile": './tmp/cert.key',
|
||||
// "sslCertFile": './tmp/cert.pem',
|
||||
"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'
|
||||
};
|
||||
|
||||
|
||||
// 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;
|
||||
|
|
Loading…
Add table
Reference in a new issue