Skip to content

Instantly share code, notes, and snippets.

@troyeagle
Created June 25, 2019 12:52
Show Gist options
  • Save troyeagle/b10774eff060cc6c6d1ed51ba8d842ec to your computer and use it in GitHub Desktop.
Save troyeagle/b10774eff060cc6c6d1ed51ba8d842ec to your computer and use it in GitHub Desktop.
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);
},
},
// 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