@zohodesk/client_build_tool
Version:
A CLI tool to build web applications and client libraries
57 lines (51 loc) • 1.47 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.decidePublicPath = decidePublicPath;
exports.modifiedServerOptions = modifiedServerOptions;
var _getServerURL = require("../../../server/getServerURL");
var _httpsOptions = require("../../../server/httpsOptions");
var _urlConcat = require("../../../server/urlConcat");
function decidePublicPath(serverExtras) {
return serverExtras.isHttps ? serverExtras.httpsUrl : serverExtras.httpUrl;
}
function modifiedServerOptions(options) {
const {
server,
context
} = options;
const {
disableContextURL
} = server;
const {
k8s
} = server;
const port = Number(server.port);
const httpsOptions = (0, _httpsOptions.httpsOptionsWithUserFriendlyError)(options);
const machineDomain = (0, _getServerURL.getServerDomain)(server);
const httpPort = port + 1;
const httpsUrl = (0, _getServerURL.getServerUrl)({
domain: machineDomain,
k8s,
port,
protocol: 'https'
});
const httpUrl = (0, _getServerURL.getServerUrl)({
domain: machineDomain,
k8s,
port: httpPort,
protocol: 'http'
});
const contextURL = disableContextURL ? '' : `/${context}`;
return {
httpsOptions,
machineDomain,
contextURL,
httpsPort: port,
httpPort,
httpsUrl: (0, _urlConcat.serverPathConcat)(httpsUrl, contextURL),
httpUrl: (0, _urlConcat.serverPathConcat)(httpUrl, contextURL),
isHttps: !!httpsOptions
};
}