Lint and port update

This commit is contained in:
Alicia Sykes 2024-04-13 12:35:21 +01:00
parent 7f45c29931
commit 4d851b6e86
2 changed files with 12 additions and 4 deletions

View File

@ -38,8 +38,8 @@ const ENDPOINTS = require('./src/utils/defaults').serviceEndpoints; // API endpo
/* Checks if app is running within a container, from env var */
const isDocker = !!process.env.IS_DOCKER;
/* Checks env var for port. If undefined, will use Port 80 for Docker, or 4000 for metal */
const port = process.env.PORT || (isDocker ? 80 : 4000);
/* Checks env var for port. If undefined, will use Port 8080 for Docker, or 4000 for metal */
const port = process.env.PORT || (isDocker ? 8080 : 4000);
/* Checks env var for host. If undefined, will use 0.0.0.0 */
const host = process.env.HOST || '0.0.0.0';

View File

@ -6,11 +6,17 @@
const isSsl = !!process.env.SSL_PRIV_KEY_PATH && !!process.env.SSL_PUB_KEY_PATH;
// eslint-disable-next-line import/no-dynamic-require
const http = require(isSsl ? 'https' : 'http');
/* Location of the server to test */
const isDocker = !!process.env.IS_DOCKER;
const port = isSsl ? (process.env.SSL_PORT || (isDocker ? 443 : 4001)) : (process.env.PORT || (isDocker ? 80 : 4000));
/* Get the port to use (depending on, if docker, if SSL) */
const sslPort = process.env.SSL_PORT || (isDocker ? 443 : 4001);
const normalPort = process.env.PORT || (isDocker ? 80 : 4000);
const port = isSsl ? sslPort : normalPort;
const host = process.env.HOST || '0.0.0.0';
const timeout = 2000;
@ -18,7 +24,9 @@ const agent = new http.Agent({
rejectUnauthorized: false, // Allow self-signed certificates
});
const requestOptions = { host, port, timeout, agent };
const requestOptions = {
host, port, timeout, agent,
};
const startTime = new Date(); // Initialize timestamp to calculate time taken