|
|
@ -5,6 +5,14 @@ function getProtocol(hostingInfo) { |
|
|
return hostingInfo.useHttps ? "https://" : "http://" |
|
|
return hostingInfo.useHttps ? "https://" : "http://" |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
async function getURLWithPath(pathIfSelfHosted) { |
|
|
|
|
|
const hostingInfo = await exports.getHostingInfo() |
|
|
|
|
|
const protocol = getProtocol(hostingInfo) |
|
|
|
|
|
const path = |
|
|
|
|
|
hostingInfo.type === exports.HostingTypes.SELF ? pathIfSelfHosted : "" |
|
|
|
|
|
return `${protocol}${hostingInfo.hostingUrl}${path}` |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
exports.HostingTypes = { |
|
|
exports.HostingTypes = { |
|
|
CLOUD: "cloud", |
|
|
CLOUD: "cloud", |
|
|
SELF: "self", |
|
|
SELF: "self", |
|
|
@ -22,10 +30,7 @@ exports.getHostingInfo = async () => { |
|
|
doc = { |
|
|
doc = { |
|
|
_id: HOSTING_DOC, |
|
|
_id: HOSTING_DOC, |
|
|
type: exports.HostingTypes.CLOUD, |
|
|
type: exports.HostingTypes.CLOUD, |
|
|
appUrl: "app.budi.live", |
|
|
hostingUrl: "app.budi.live", |
|
|
workerUrl: "", |
|
|
|
|
|
minioUrl: "", |
|
|
|
|
|
couchUrl: "", |
|
|
|
|
|
templatesUrl: "prod-budi-templates.s3-eu-west-1.amazonaws.com", |
|
|
templatesUrl: "prod-budi-templates.s3-eu-west-1.amazonaws.com", |
|
|
useHttps: true, |
|
|
useHttps: true, |
|
|
} |
|
|
} |
|
|
@ -37,30 +42,24 @@ exports.getAppUrl = async appId => { |
|
|
const hostingInfo = await exports.getHostingInfo() |
|
|
const hostingInfo = await exports.getHostingInfo() |
|
|
const protocol = getProtocol(hostingInfo) |
|
|
const protocol = getProtocol(hostingInfo) |
|
|
let url |
|
|
let url |
|
|
if (hostingInfo.type === "cloud") { |
|
|
if (hostingInfo.type === exports.HostingTypes.CLOUD) { |
|
|
url = `${protocol}${appId}.${hostingInfo.appUrl}` |
|
|
url = `${protocol}${appId}.${hostingInfo.hostingUrl}` |
|
|
} else { |
|
|
} else { |
|
|
url = `${protocol}${hostingInfo.appUrl}` |
|
|
url = `${protocol}${hostingInfo.hostingUrl}/app` |
|
|
} |
|
|
} |
|
|
return url |
|
|
return url |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
exports.getWorkerUrl = async () => { |
|
|
exports.getWorkerUrl = async () => { |
|
|
const hostingInfo = await exports.getHostingInfo() |
|
|
return getURLWithPath("/worker") |
|
|
const protocol = getProtocol(hostingInfo) |
|
|
|
|
|
return `${protocol}${hostingInfo.workerUrl}` |
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
exports.getMinioUrl = async () => { |
|
|
exports.getMinioUrl = async () => { |
|
|
const hostingInfo = await exports.getHostingInfo() |
|
|
return getURLWithPath("/") |
|
|
const protocol = getProtocol(hostingInfo) |
|
|
|
|
|
return `${protocol}${hostingInfo.minioUrl}` |
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
exports.getCouchUrl = async () => { |
|
|
exports.getCouchUrl = async () => { |
|
|
const hostingInfo = await exports.getHostingInfo() |
|
|
return getURLWithPath("/db") |
|
|
const protocol = getProtocol(hostingInfo) |
|
|
|
|
|
return `${protocol}${hostingInfo.couchUrl}` |
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
exports.getTemplatesUrl = async (appId, type, name) => { |
|
|
exports.getTemplatesUrl = async (appId, type, name) => { |
|
|
|