Skip to content

Commit 9b932a2

Browse files
committed
feat(config): export getConfig to library entrypoint
1 parent 1edfdd9 commit 9b932a2

File tree

3 files changed

+24
-16
lines changed

3 files changed

+24
-16
lines changed

src/config/index.js

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,22 @@
11
import nconf from 'nconf';
22
import defaults from './defaults';
33

4-
nconf
5-
.argv({
6-
separator: '__',
7-
parseValues: true,
8-
})
9-
.env({
10-
separator: '__',
11-
lowerCase: true,
12-
parseValues: true,
13-
});
4+
const get = () => {
5+
nconf.reset();
146

15-
nconf.defaults(defaults);
7+
nconf
8+
.argv({
9+
separator: '__',
10+
parseValues: true,
11+
})
12+
.env({
13+
separator: '__',
14+
lowerCase: true,
15+
parseValues: true,
16+
});
17+
nconf.defaults(defaults);
1618

17-
export default nconf;
19+
return nconf.get();
20+
};
21+
22+
export default get;

src/index.js

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,11 @@ const handle = (signal) => {
1212
process.on('SIGINT', handle);
1313
process.on('SIGTERM', handle);
1414

15+
const parsedConfig = config.get();
16+
1517
socketServer({
16-
baseUrl: config.get('base_url'),
17-
staticPath: config.get('static_path'),
18-
port: config.get('port'),
19-
pingInterval: config.get('ping_interval'),
18+
baseUrl: parsedConfig.base_url,
19+
staticPath: parsedConfig.static_path,
20+
port: parsedConfig.port,
21+
pingInterval: parsedConfig.ping_interval,
2022
});

src/lib.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
1+
export { default as getConfig } from './config';
12
export { default as defaultConfig } from './config/defaults';
23
export { default as socketServer } from './socketserver';

0 commit comments

Comments
 (0)