Skip to content

Commit

Permalink
chore: add new config features and associated functions
Browse files Browse the repository at this point in the history
  • Loading branch information
JamieSlome committed Feb 9, 2024
1 parent bd4d0bb commit b3b5fa8
Show file tree
Hide file tree
Showing 2 changed files with 80 additions and 2 deletions.
9 changes: 8 additions & 1 deletion proxy.config.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
{
"proxyUrl": "https://github.com",
"cookieSecret": "cookie secret",
"sessionMaxAgeHours": 12,
"tempPassword": {
"sendEmail": false,
"emailConfig": {}
Expand All @@ -25,7 +27,7 @@
"options": {
"useNewUrlParser": true,
"useUnifiedTopology": true,
"sslValidate": false,
"tlsAllowInvalidCertificates": false,
"ssl": true
},
"enabled": false
Expand All @@ -48,6 +50,11 @@
}
}
],
"api": {
"github": {
"baseUrl": "https://api.github.com"
}
},
"commitConfig": {
"author": {
"email": {
Expand Down
73 changes: 72 additions & 1 deletion src/config/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,24 @@ let _authorisedList = defaultSettings.authorisedList;
let _database = defaultSettings.sink;
let _authentication = defaultSettings.authentication;
let _tempPassword = defaultSettings.tempPassword;
let _proxyUrl = defaultSettings.proxyUrl;
let _api = defaultSettings.api;
let _cookieSecret = defaultSettings.cookieSecret;
let _sessionMaxAgeHours = defaultSettings.sessionMaxAgeHours;
const _commitConfig = defaultSettings.commitConfig;
const _attestationConfig = defaultSettings.attestationConfig;
const _privateOrganizations = defaultSettings.privateOrganizations;
const _urlShortener = defaultSettings.urlShortener;
const _contactEmail = defaultSettings.contactEmail;

// Get configured proxy URL
const getProxyUrl = () => {
if (_userSettings !== null && _userSettings.proxyUrl) {
_proxyUrl = _userSettings.proxyUrl;

Check warning on line 27 in src/config/index.js

View check run for this annotation

Codecov / codecov/patch

src/config/index.js#L26-L27

Added lines #L26 - L27 were not covered by tests
}

return _proxyUrl;

Check warning on line 30 in src/config/index.js

View check run for this annotation

Codecov / codecov/patch

src/config/index.js#L30

Added line #L30 was not covered by tests
};

// Gets a list of authorised repositories
const getAuthorisedList = () => {
Expand Down Expand Up @@ -70,10 +88,63 @@ const logConfiguration = () => {
console.log(`authentication = ${JSON.stringify(getAuthentication())}`);
};

// logConfiguration();
const getAPIs = () => {
if (_userSettings && _userSettings.api) {
_api = _userSettings.api;

Check warning on line 93 in src/config/index.js

View check run for this annotation

Codecov / codecov/patch

src/config/index.js#L92-L93

Added lines #L92 - L93 were not covered by tests
}
return _api;

Check warning on line 95 in src/config/index.js

View check run for this annotation

Codecov / codecov/patch

src/config/index.js#L95

Added line #L95 was not covered by tests
};

const getCookieSecret = () => {
if (_userSettings && _userSettings.cookieSecret) {
_cookieSecret = _userSettings.cookieSecret;

Check warning on line 100 in src/config/index.js

View check run for this annotation

Codecov / codecov/patch

src/config/index.js#L99-L100

Added lines #L99 - L100 were not covered by tests
}
return _cookieSecret;

Check warning on line 102 in src/config/index.js

View check run for this annotation

Codecov / codecov/patch

src/config/index.js#L102

Added line #L102 was not covered by tests
};

const getSessionMaxAgeHours = () => {
if (_userSettings && _userSettings.sessionMaxAgeHours) {
_sessionMaxAgeHours = _userSettings.sessionMaxAgeHours;

Check warning on line 107 in src/config/index.js

View check run for this annotation

Codecov / codecov/patch

src/config/index.js#L106-L107

Added lines #L106 - L107 were not covered by tests
}
return _sessionMaxAgeHours;

Check warning on line 109 in src/config/index.js

View check run for this annotation

Codecov / codecov/patch

src/config/index.js#L109

Added line #L109 was not covered by tests
};

// Get commit related configuration
const getCommitConfig = () => {
return _commitConfig;
};

// Get attestation related configuration
const getAttestationConfig = () => {
return _attestationConfig;

Check warning on line 119 in src/config/index.js

View check run for this annotation

Codecov / codecov/patch

src/config/index.js#L119

Added line #L119 was not covered by tests
};

// Get private organizations related configuration
const getPrivateOrganizations = () => {
return _privateOrganizations;
};

// Get URL shortener
const getURLShortener = () => {
return _urlShortener;

Check warning on line 129 in src/config/index.js

View check run for this annotation

Codecov / codecov/patch

src/config/index.js#L129

Added line #L129 was not covered by tests
};

// Get contact e-mail address
const getContactEmail = () => {
return _contactEmail;

Check warning on line 134 in src/config/index.js

View check run for this annotation

Codecov / codecov/patch

src/config/index.js#L134

Added line #L134 was not covered by tests
};

exports.getAPIs = getAPIs;
exports.getProxyUrl = getProxyUrl;
exports.getAuthorisedList = getAuthorisedList;
exports.getDatabase = getDatabase;
exports.logConfiguration = logConfiguration;
exports.getAuthentication = getAuthentication;
exports.getTempPasswordConfig = getTempPasswordConfig;
exports.getCookieSecret = getCookieSecret;
exports.getSessionMaxAgeHours = getSessionMaxAgeHours;
exports.getCommitConfig = getCommitConfig;
exports.getAttestationConfig = getAttestationConfig;
exports.getPrivateOrganizations = getPrivateOrganizations;
exports.getURLShortener = getURLShortener;
exports.getContactEmail = getContactEmail;

0 comments on commit b3b5fa8

Please sign in to comment.