Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 0 additions & 22 deletions config/autoconfig.js

This file was deleted.

37 changes: 23 additions & 14 deletions config/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,13 @@
* See https://github.com/mozilla/node-convict/blob/master/README.md for details.
*/
var convict = require('convict');
var fs = require('fs');

module.exports = function () {

// Check if we need to auto configure for a fast start.
var env = process.env.NODE_ENV || 'dev';
var configFile = process.env.FREIGHT_CONFIG || __dirname + '/' + env + '.json';

require('./autoconfig')(configFile);

var conf = convict({
env: {
doc: 'The applicaton environment.',
Expand Down Expand Up @@ -40,43 +38,51 @@ module.exports = function () {
limit: {
doc: 'The bundle transmission size limit, in kb.',
format: 'nat',
default: 500
default: 500,
env: 'LIMIT'
},
password: {
doc: 'The password that is used to create Freight bundles.',
format: String,
default: ''
default: '',
env: 'FREIGHT_PASSWORD'
},
storage: {
// TODO: You need to create this directory if it does not exist.
// This directory is also used as a static file directory for Freight bundles.
doc: 'Default bundle storage directory. Make sure it is somewhere in the Freight Server directory.',
format: String,
default: __dirname + '/../storage'
default: __dirname + '/../storage',
env: 'STORAGE_DIRECTORY'
},
tempDir: {
// TODO: You need to create this directory if it does not exist.
doc: 'Default directory for temporary files.',
format: String,
default: __dirname + '/../temp'
default: __dirname + '/../temp',
env: 'TEMP_DIRECTORY'
},
// Redis config, see https://github.com/learnboost/kue#redis-connection-settings
redis: {
port: {
doc: 'Redis Port',
format: 'port',
default: 6379
default: 6379,
env: 'REDIS_PORT'
},
host: {
doc: 'Redis IP address to bind.',
format: 'ipaddress',
default: '127.0.0.1'
format: String,
default: '127.0.0.1',
env: 'REDIS_HOST'
},
auth: {
doc: 'Redis Password.',
format: String,
default: ''
default: '',
env: 'REDIS_PASSWORD'
},
// TODO : see how we can extract redis options from env variables
options: {
doc: 'Redis Options.',
format: Object,
Expand All @@ -87,14 +93,17 @@ module.exports = function () {
delay: {
doc: 'Repository update check delay in milliseconds',
format: 'nat',
default: 60 * 60000
default: 60 * 60000,
env: 'TRACK_DELAY'
}
}
});

// load environment dependent configuration
// TODO: development only for now, change it later.
conf.loadFile(configFile);
if (fs.existsSync(configFile)) {
// TODO: development only for now, change it later.
conf.loadFile(configFile);
}
// perform configuration validation
conf.validate();

Expand Down