summaryrefslogtreecommitdiffstats
path: root/server/api/backends.js
diff options
context:
space:
mode:
Diffstat (limited to 'server/api/backends.js')
-rw-r--r--server/api/backends.js34
1 files changed, 33 insertions, 1 deletions
diff --git a/server/api/backends.js b/server/api/backends.js
index 77506ba..7729588 100644
--- a/server/api/backends.js
+++ b/server/api/backends.js
@@ -4,6 +4,7 @@ const ExternalBackends = require(path.join(__appdir, 'lib', 'external-backends')
var db = require(path.join(__appdir, 'lib', 'sequelize'))
var express = require('express')
var router = express.Router()
+var noAuthRouter = express.Router()
// GET requests.
@@ -119,7 +120,38 @@ router.get('/:id/synctypes', (req, res) => {
})
})
-// POST requests
+// vvvv TEST MEHTOD !!!! <----------------------------------------------------------
+noAuthRouter.get('/:id/test/getObjectTree', (req, res) => {
+ const id = req.params.id
+ db.backend.findOne({ where: { id: id } }).then(backend => {
+ if (backend) {
+ const ba = new ExternalBackends()
+ const instance = ba.getInstance(backend.type)
+
+ // Get the backend with all the mapped groups. ! Only groups can have childs !
+ db.backend.findOne({ where: { id: backend.id }, include: ['mappedGroups'] }).then(b => {
+ var objectData = []
+ // Put all groups in the array to make a one session call which returns all needed informations.
+ b.mappedGroups.forEach(mGroup => {
+ const mG = mGroup.backend_x_group
+ const eid = mG.externalId
+ const gid = mGroup.id
+ objectData.push({ eid: eid, gid: gid })
+ })
+ // Get all the information needed from the backend instance. (For all object ids in the array)
+ var promise = new Promise(function (resolve) {
+ // resolve(instance.getDataTree(backend.credentials, objectData.slice(0, 200)))
+ resolve(instance.getDataTree(backend.credentials, objectData))
+ })
+ promise.then(data => {
+ res.send({ length: data.length, result: data })
+ })
+ })
+ } else res.send({ error: 'error' })
+ })
+})
+module.exports.noAuthRouter = noAuthRouter
+// ^^^^ TEST MEHTOD !!!! <----------------------------------------------------------
/*
* id: <BACKEND_ID>