signalk-server
Version:
An implementation of a [Signal K](http://signalk.org) server for boats.
56 lines (55 loc) • 2.15 kB
JavaScript
;
/*
* Copyright 2017 Teppo Kurki <teppo.kurki@iki.fi>
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
Object.defineProperty(exports, "__esModule", { value: true });
exports.getHttpPort = exports.getSslPort = void 0;
exports.getPrimaryPort = getPrimaryPort;
exports.getSecondaryPort = getSecondaryPort;
exports.getExternalPort = getExternalPort;
const SD_LISTEN_FDS_START = 3;
const getSslPort = (app) => Number(process.env?.SSLPORT) || app.config.settings.sslport || 3443;
exports.getSslPort = getSslPort;
const getHttpPort = (app) => Number(process.env?.PORT) || app.config.settings.port || 3000;
exports.getHttpPort = getHttpPort;
function getPrimaryPort(app) {
if (Number(process.env.LISTEN_FDS) > 0) {
return {
fd: SD_LISTEN_FDS_START
};
}
return app.config.settings.ssl ? (0, exports.getSslPort)(app) : (0, exports.getHttpPort)(app);
}
// eslint-disable-next-line @typescript-eslint/no-explicit-any
function getSecondaryPort(app) {
if (Number(process.env.LISTEN_FDS) > 0) {
if (Number(process.env.LISTEN_FDS) !== 2) {
return false;
}
return {
fd: SD_LISTEN_FDS_START + 1
};
}
return app.config.settings.ssl ? (0, exports.getHttpPort)(app) : -7777;
}
function getExternalPort(app) {
if (Number(process.env?.EXTERNALPORT) > 0) {
return Number(process.env?.EXTERNALPORT);
}
if (app.config.settings.proxy_port) {
return app.config.settings.proxy_port;
}
return app.config.settings.ssl ? (0, exports.getSslPort)(app) : (0, exports.getHttpPort)(app);
}
//# sourceMappingURL=ports.js.map