-
Notifications
You must be signed in to change notification settings - Fork 22
Open
Description
Say I am writing an SDK (just suppose…)
Is the following reasonable, and if so, should it be documented as a best practice?
OLD:
var appEnv = require('cfenv').getAppEnv();
var someClient = require('Some Random Thing').setup({ credentials: appEnv.getServiceCreds(/Something.*/) });
IMPROVED?
var appEnv = require('cfenv').getAppEnv();
var someClient = require('Some Random Thing').setup({ appEnv: appEnv });
implemented within the SDK by:
… function setup(opts) {
if(opts.appEnv && !opts.credentials) { // if appEnv is available, use it
opts.credentials = opts.appEnv.getServiceCreds( someRegex );
}
Any pitfalls? My idea is to reduce the amount of copy and paste user code. User can just pass in appEnv if they have one, otherwise credentials can be supplied.
Metadata
Metadata
Assignees
Labels
No labels