summaryrefslogtreecommitdiffstats
path: root/server/api/backends.js
diff options
context:
space:
mode:
authorJannik Schönartz2018-07-30 05:21:35 +0200
committerJannik Schönartz2018-07-30 05:21:35 +0200
commitf5572fb6fd72224ff64868a03ab81fa5927764e8 (patch)
tree71c73020f800816e35de8cccd09f2b235fba9ad0 /server/api/backends.js
parent[webapp] Changed post/get method names to match the restructured backend again. (diff)
downloadbas-f5572fb6fd72224ff64868a03ab81fa5927764e8.tar.gz
bas-f5572fb6fd72224ff64868a03ab81fa5927764e8.tar.xz
bas-f5572fb6fd72224ff64868a03ab81fa5927764e8.zip
[server] Refactored redundant variable naming. Fixed eslint. :|
Diffstat (limited to 'server/api/backends.js')
-rw-r--r--server/api/backends.js30
1 files changed, 15 insertions, 15 deletions
diff --git a/server/api/backends.js b/server/api/backends.js
index e4d3ff6..c345aa8 100644
--- a/server/api/backends.js
+++ b/server/api/backends.js
@@ -70,15 +70,15 @@ module.exports.get = {
module.exports.post = {
save: function (req, res) {
// Save credentials in the db.
- const formData = req.body
- const credentialString = JSON.stringify(formData.backendCredentials)
+ const backend = req.body
+ const credentialString = JSON.stringify(backend.credentials)
- if (formData.backendId === 0) {
+ if (backend.id === 0) {
// Insert new backend in the db.
- db.backend.create({ name: formData.backendName, type: formData.backendType, credentials: credentialString })
+ db.backend.create({ name: backend.name, type: backend.type, credentials: credentialString })
} else {
// Update an existing backend in the db.
- db.backend.update({ name: formData.backendName, type: formData.backendType, credentials: credentialString }, { where: { id: formData.backendId } })
+ db.backend.update({ name: backend.name, type: backend.type, credentials: credentialString }, { where: { id: backend.id } })
}
// db.backend.findOne({})
@@ -98,21 +98,21 @@ module.exports.post = {
checkConnection: function (req, res) {
const id = req.body.id
- var getBackend = null
+ var getBackend = null
if (id) getBackend = db.backend.findOne({ where: { id: id } })
- else getBackend = new Promise(resolve => resolve(req.body))
+ else getBackend = new Promise(resolve => resolve(req.body))
- getBackend.then(backend => {
+ getBackend.then(backend => {
var bCredentials = {
type: backend.type,
credentials: backend.credentials
}
// Creating the backend instance and calling the specific checkConnection.
- const b = new ExternalBackends()
- const instance = b.getInstance(bCredentials.type)
- instance.checkConnection(bCredentials).then(connection => {
- res.status(200).send({ success: connection.success, msg: connection.msg })
- })
- })
+ const b = new ExternalBackends()
+ const instance = b.getInstance(bCredentials.type)
+ instance.checkConnection(bCredentials).then(connection => {
+ res.status(200).send({ success: connection.success, msg: connection.msg })
+ })
+ })
}
-} \ No newline at end of file
+}