diff --git a/bin/config.default.json b/bin/config.default.json new file mode 100644 index 0000000..6f80438 --- /dev/null +++ b/bin/config.default.json @@ -0,0 +1,5 @@ +{ + "debug" : false, + "port" : 1571, + "max_file_size" : 2000 +} diff --git a/bin/keppler.class.js b/bin/keppler.class.js index c228007..14015fa 100644 --- a/bin/keppler.class.js +++ b/bin/keppler.class.js @@ -1,11 +1,12 @@ 'use strict' // Depedencies -let path = require( 'path' ), - colors = require( 'colors' ), - ip = require( 'ip' ), - Site = require( '../site/site.class.js' ), - Watcher = require( '../watcher/watcher.class.js' ) +let path = require( 'path' ), + colors = require( 'colors' ), + ip = require( 'ip' ), + Site = require( '../site/site.class.js' ), + Watcher = require( '../watcher/watcher.class.js' ), + default_config = require( './config.default.json' ) /** * Keppler class @@ -35,22 +36,25 @@ class Keppler // Defaults if( typeof _options.debug === 'undefined' ) { - if( this.arguments.length ) + if( this.arguments.length > 1 ) { _options.debug = this.arguments[ this.arguments.length - 1 ] === 'true' ? true : false } else { - _options.debug = false + _options.debug = default_config.debug } } if( typeof _options.port === 'undefined' ) - _options.port = 1571 + _options.port = default_config.port if( typeof _options.domain === 'undefined' ) _options.domain = `http://${ip.address()}:${_options.port}` + if( typeof _options.max_file_size === 'undefined' ) + _options.max_file_size = default_config.max_file_size + // Save this.options = _options } @@ -93,10 +97,11 @@ class Keppler set_watcher() { this.watcher = new Watcher( { - port : this.options.port, - domain: this.options.domain, - debug : this.options.debug, - name : this.arguments[ 0 ] + port : this.options.port, + domain : this.options.domain, + debug : this.options.debug, + max_file_size: this.options.max_file_size, + name : this.arguments[ 0 ] } ) } } diff --git a/watcher/watcher.class.js b/watcher/watcher.class.js index 2f89aa3..f4292c9 100644 --- a/watcher/watcher.class.js +++ b/watcher/watcher.class.js @@ -43,6 +43,9 @@ class Watcher if( typeof _options.domain === 'undefined' ) _options.domain = `http://${ip.address()}:${_options.port}` + if( typeof _options.max_file_size === 'undefined' ) + _options.max_file_size = 2000 + // Save this.options = _options } @@ -104,7 +107,7 @@ class Watcher // Retrieve stats fs.stat( _path, ( error, stats ) => { - if( stats.size > 999999 ) + if( stats.size > this.options.max_file_size ) file.can_read = false // Read @@ -145,7 +148,7 @@ class Watcher // Retrieve stats fs.stat( _path, ( error, stats ) => { - if( stats.size > 999999 ) + if( stats.size > this.options.max_file_size ) file.can_read = false // Read