1 | 'use strict';
|
2 |
|
3 | var assert = require('assert-plus');
|
4 | var cache = require('./cache');
|
5 |
|
6 | var DEFAULT_AUTH_CACHE_TIMEOUT_MS = 300000;
|
7 |
|
8 | module.exports = function Config(config, configName) {
|
9 | assert.object(config, 'config');
|
10 | assert.string(configName, 'configName');
|
11 |
|
12 | var cfg = function(ptr, $default) {
|
13 | return cache.get('cfg', ptr, 0, function(){
|
14 | var res = config.get(configName, ptr);
|
15 | if (res === undefined) {
|
16 | res = $default;
|
17 | }
|
18 | return res;
|
19 | });
|
20 | };
|
21 | cfg.authCacheTTL = cfg.bind(null, '#/trusted_endpoint/auth_cache_timeout_ms', DEFAULT_AUTH_CACHE_TIMEOUT_MS);
|
22 | cfg.lax = cfg.bind(null, '#/trusted_endpoint/lax');
|
23 | cfg.keyId = cfg.bind(null, '#/trusted_endpoint/key_id');
|
24 | return cfg;
|
25 | };
|