Skip to content

Commit

Permalink
Merge pull request toptal#350 from seejohnrun/specify-config-on-boot
Browse files Browse the repository at this point in the history
Allow setting config.js alternative on boot
  • Loading branch information
seejohnrun authored Oct 7, 2020
2 parents a108dba + f255928 commit 5d2965f
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 `<config-path>` as well)

## Settings

Expand All @@ -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!
Expand Down
3 changes: 2 additions & 1 deletion server.js
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand Down

0 comments on commit 5d2965f

Please sign in to comment.