Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
import BackendlessRTClient from 'backendless-rt-client'
import Utils from './utils'
import LocalVars from './local-vars'
import { getCurrentUserToken } from './users/current-user'
let rtClient = null
const rtClientId = Utils.uuid()
export const RTListeners = BackendlessRTClient.Listeners
export const RTScopeConnector = BackendlessRTClient.ScopeConnector
export const RTClient = {
get subscriptions() {
return rtClient.subscriptions
},
get methods() {
return rtClient.methods
}
}
export const checkUsesInBusinessLogic = target => {
if (LocalVars.ServerCode) {
// temporarily disable this limitation
import BackendlessRTClient from 'backendless-rt-client'
import Utils from './utils'
import LocalVars from './local-vars'
import { getCurrentUserToken } from './users/current-user'
let rtClient = null
const rtClientId = Utils.uuid()
export const RTListeners = BackendlessRTClient.Listeners
export const RTScopeConnector = BackendlessRTClient.ScopeConnector
export const RTClient = {
get subscriptions() {
return rtClient.subscriptions
},
get methods() {
return rtClient.methods
}
}
export const checkUsesInBusinessLogic = target => {
if (LocalVars.ServerCode) {
// temporarily disable this limitation
// throw new Error(`"${target}" is not supported inside Business Logic.`)
export const initRTClient = () => {
if (rtClient) {
rtClient.terminate()
}
rtClient = new BackendlessRTClient({
appId : LocalVars.applicationId,
lookupPath: `${LocalVars.appPath}/rt/lookup`,
debugMode : LocalVars.debugMode,
connectQuery() {
return {
apiKey : LocalVars.secretKey,
userToken: getCurrentUserToken(),
clientId : rtClientId,
}
}
})
}