Skip to content

Commit

Permalink
feat(config): export getConfig to library entrypoint
Browse files Browse the repository at this point in the history
  • Loading branch information
ttshivers committed Aug 23, 2020
1 parent 1edfdd9 commit 9b932a2
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 16 deletions.
29 changes: 17 additions & 12 deletions src/config/index.js
Original file line number Diff line number Diff line change
@@ -1,17 +1,22 @@
import nconf from 'nconf';
import defaults from './defaults';

nconf
.argv({
separator: '__',
parseValues: true,
})
.env({
separator: '__',
lowerCase: true,
parseValues: true,
});
const get = () => {
nconf.reset();

nconf.defaults(defaults);
nconf
.argv({
separator: '__',
parseValues: true,
})
.env({
separator: '__',
lowerCase: true,
parseValues: true,
});
nconf.defaults(defaults);

export default nconf;
return nconf.get();
};

export default get;
10 changes: 6 additions & 4 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,11 @@ const handle = (signal) => {
process.on('SIGINT', handle);
process.on('SIGTERM', handle);

const parsedConfig = config.get();

socketServer({
baseUrl: config.get('base_url'),
staticPath: config.get('static_path'),
port: config.get('port'),
pingInterval: config.get('ping_interval'),
baseUrl: parsedConfig.base_url,
staticPath: parsedConfig.static_path,
port: parsedConfig.port,
pingInterval: parsedConfig.ping_interval,
});
1 change: 1 addition & 0 deletions src/lib.js
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
export { default as getConfig } from './config';
export { default as defaultConfig } from './config/defaults';
export { default as socketServer } from './socketserver';

0 comments on commit 9b932a2

Please sign in to comment.