joyent-portal/packages/cloudapi-gql/src/credentials.js
2017-09-07 17:28:56 +01:00

29 lines
666 B
JavaScript

const path = require('path');
const json = (() => {
try {
const res = require('dotenv').config({
path: path.join(__dirname, '../.env'),
silent: true
});
if (res.error) {
throw res.error;
}
} catch (err) {
try {
return require('../credentials.json');
} catch (err) {
return {};
}
}
return {};
})();
module.exports = {
url: process.env.SDC_URL || json.SDC_URL || json.url || '',
account: process.env.SDC_ACCOUNT || json.SDC_ACCOUNT || json.account || '',
user: process.env.SDC_USER || json.SDC_USER || json.user || '',
keyId: process.env.SDC_KEY_ID || json.SDC_KEY_ID || json.keyId || ''
};