/* global __appdir */ const fs = require('fs') const path = require('path') class ExternalBackends { getBackends () { var files = fs.readdirSync(path.join(__appdir, 'lib', 'external-backends', 'backends')) return files } getCredentials () { console.log('If this method gets called the backend class has NOT IMPLEMENTED the getCredentials method!') return null } getInstance (type) { const bList = this.getBackends() const bType = type + '-backend.js' // Check if it's a valid backend type. if (bList.indexOf(bType) === -1) { console.log(bType + ' is not a valid backend type.') return null } const backend = new (require(path.join(__appdir, 'lib', 'external-backends', 'backends', bType)))() return backend } getSyncTypes () { return [] } async checkConnection (backend) { console.log('If this method gets called the backend class has NOT IMPLEMENTED the checkConnection method!') return null } // Return an empty array [] if the backends doesn't have such a function. async getObjectTypes (credentials) { return [] } } module.exports = ExternalBackends