You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
The text was updated successfully, but these errors were encountered:
Ya, that seems reasonable. I'd document your "Some Random Thing" package as providing a setup() method that takes an options object, where one key can be appEnv and is expected to be the result of a cfenv.getAppEnv() call.
I'm not sure about documenting it as best practice, since yours is the first suggestion I've seen of someone wanting to do this. Let us know how it works out! Maybe it WILL BE a best practice!
Say I am writing an SDK (just suppose…)
Is the following reasonable, and if so, should it be documented as a best practice?
OLD:
IMPROVED?
implemented within the SDK by:
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.The text was updated successfully, but these errors were encountered: