Created
June 25, 2019 12:52
-
-
Save troyeagle/b10774eff060cc6c6d1ed51ba8d842ec to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
exports.oss = { | |
client: { | |
async clientLoadConfig(config, app) { | |
assert(app && app.name === 'oss-async-load'); | |
return Object.assign({ something: 'individual' }, config); | |
}, | |
}, | |
default: { | |
async loadConfig(config, app) { | |
assert(app && app.name === 'oss-async-load'); | |
return Object.assign({}, { something: 'basic' }, config); | |
}, | |
}, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// line 17 | |
app.addSingleton('oss', async (config, app) => { | |
config = Object.assign({}, config, { urllib: app.httpclient }); | |
if (is.function(config.loadConfig)) { | |
const result = config.loadConfig(config, app); | |
config = Object.assign({}, is.promise(result) ? (await result) : result, config); | |
delete config.loadConfig; | |
} | |
if (is.function(config.clientLoadConfig)) { | |
const result = config.clientLoadConfig(config, app); | |
config = Object.assign({}, is.promise(result) ? (await result) : result, config); | |
delete config.clientLoadConfig; | |
} | |
// the rest | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment