From f255928af70756887f1d3fb1ec6e9a5aeb581444 Mon Sep 17 00:00:00 2001 From: John Crepezzi Date: Tue, 6 Oct 2020 22:15:13 -0400 Subject: [PATCH] Allow setting config.js alternative on boot Closes #105 --- README.md | 4 ++-- server.js | 3 ++- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 46bd48c..b42c844 100644 --- a/README.md +++ b/README.md @@ -31,7 +31,7 @@ STDOUT. Check the README there for more details and usages. 1. Download the package, and expand it 2. Explore the settings inside of config.js, but the defaults should be good 3. `npm install` -4. `npm start` +4. `npm start` (you may specify an optional `` as well) ## Settings @@ -52,7 +52,7 @@ STDOUT. Check the README there for more details and usages. When present, the `rateLimits` option enables built-in rate limiting courtesy of `connect-ratelimit`. Any of the options supported by that library can be -used and set in `config.json`. +used and set in `config.js`. See the README for [connect-ratelimit](https://github.com/dharmafly/connect-ratelimit) for more information! diff --git a/server.js b/server.js index 63f95ea..0837a03 100644 --- a/server.js +++ b/server.js @@ -11,7 +11,8 @@ var connect_rate_limit = require('connect-ratelimit'); var DocumentHandler = require('./lib/document_handler'); // Load the configuration and set some defaults -var config = JSON.parse(fs.readFileSync('./config.js', 'utf8')); +const configPath = process.argv.length <= 2 ? 'config.js' : process.argv[2]; +const config = JSON.parse(fs.readFileSync(configPath, 'utf8')); config.port = process.env.PORT || config.port || 7777; config.host = process.env.HOST || config.host || 'localhost';