-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Apply automatic ESLint fixes for all source files
- Loading branch information
Showing
20 changed files
with
1,062 additions
and
1,112 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,15 @@ | ||
exports.CONFIG_FILE = "/ldap/config/config.yml" | ||
exports.API_SLUG = "api" | ||
exports.WHOAMI_AP = "/whoami?only_allow_authenticated=true" | ||
exports.CSRF_AP = "/csrftoken" | ||
exports.LOGIN_AP = "/login" | ||
exports.INFO_AP = "/info" | ||
exports.GROUPMEMBERS_AP = "/groups/members?with_deleted=false" | ||
exports.IDS = "&ids[]=" | ||
exports.PERSONS_AP = "/persons" | ||
exports.GROUPS_AP = "/groups" | ||
exports.LDAPID_FIELD = "ncuid" | ||
exports.LDAP_OU_USERS = "users" | ||
exports.LDAP_OU_GROUPS = "groups" | ||
exports.LDAP_OBJCLASS_USER = "CTPerson"; | ||
exports.LDAP_OBJCLASS_GROUP = "group"; | ||
exports.CONFIG_FILE = '/ldap/config/config.yml'; | ||
exports.API_SLUG = 'api'; | ||
exports.WHOAMI_AP = '/whoami?only_allow_authenticated=true'; | ||
exports.CSRF_AP = '/csrftoken'; | ||
exports.LOGIN_AP = '/login'; | ||
exports.INFO_AP = '/info'; | ||
exports.GROUPMEMBERS_AP = '/groups/members?with_deleted=false'; | ||
exports.IDS = '&ids[]='; | ||
exports.PERSONS_AP = '/persons'; | ||
exports.GROUPS_AP = '/groups'; | ||
exports.LDAPID_FIELD = 'ncuid'; | ||
exports.LDAP_OU_USERS = 'users'; | ||
exports.LDAP_OU_GROUPS = 'groups'; | ||
exports.LDAP_OBJCLASS_USER = 'CTPerson'; | ||
exports.LDAP_OBJCLASS_GROUP = 'group'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,54 +1,52 @@ | ||
const log = require("./logging"); | ||
const c = require("./constants"); | ||
const axios = require("axios").default; | ||
|
||
const log = require('./logging'); | ||
const c = require('./constants'); | ||
const axios = require('axios').default; | ||
|
||
exports.ChurchToolsError = (message) => { | ||
err = new Error(message) | ||
err = new Error(message); | ||
log.error(message); | ||
err.name = "ChurchToolsError" | ||
err.name = 'ChurchToolsError'; | ||
return err; | ||
} | ||
}; | ||
|
||
exports.ChurchToolsFatalError = (message) => { | ||
err = new Error(message) | ||
err = new Error(message); | ||
log.error(message); | ||
err.name = "ChurchToolsFatalError" | ||
err.name = 'ChurchToolsFatalError'; | ||
return err; | ||
} | ||
|
||
uriTrailingSlash = (uri) => (uri.slice(-1) !== "/" ? uri + "/" : uri); | ||
}; | ||
|
||
uriTrailingSlash = (uri) => (uri.slice(-1) !== '/' ? `${uri}/` : uri); | ||
|
||
exports.result = (result, success, failed) => { | ||
if (result && result.hasOwnProperty("data")) { | ||
if (result && result.hasOwnProperty('data')) { | ||
if (success) success(result); | ||
log.debug(JSON.stringify(result.data)); | ||
return result.data | ||
} else if (result && result.hasOwnProperty("status") && result.status === "success") { | ||
return result.data; | ||
} if (result && result.hasOwnProperty('status') && result.status === 'success') { | ||
if (success) success(result); | ||
log.debug(JSON.stringify(result.data)); | ||
return result.data | ||
} else if (result && result.hasOwnProperty("message")) { | ||
return result.data; | ||
} if (result && result.hasOwnProperty('message')) { | ||
if (failed) failed(); | ||
throw this.ChurchToolsError(result.message); | ||
} else if (result && result.hasOwnProperty("status") && | ||
[400, 401, 403, 404, 405, 500, 501, 502, 503, 504].includes(result.status)) { | ||
} else if (result && result.hasOwnProperty('status') | ||
&& [400, 401, 403, 404, 405, 500, 501, 502, 503, 504].includes(result.status)) { | ||
if (failed) failed(); | ||
throw this.ChurchToolsError("No Session or connection problems"); | ||
throw this.ChurchToolsError('No Session or connection problems'); | ||
} else { | ||
log.error(JSON.stringify(result)); | ||
throw this.ChurchToolsFatalError("Unexpected Error"); | ||
throw this.ChurchToolsFatalError('Unexpected Error'); | ||
} | ||
} | ||
}; | ||
|
||
exports.request = async (request, success, failed) => { | ||
log.debug(JSON.stringify(request)) | ||
var result = {} | ||
log.debug(JSON.stringify(request)); | ||
let result = {}; | ||
try { | ||
result = await axios(request) | ||
result = await axios(request); | ||
} catch (err) { | ||
throw this.ChurchToolsError(err.message); | ||
} | ||
return this.result(result, success, failed) | ||
} | ||
return this.result(result, success, failed); | ||
}; |
Oops, something went wrong.