Resolved bug in Client with .env config migration

This commit is contained in:
Logan Cusano
2023-05-07 19:31:53 -04:00
parent 2c25be1de7
commit 48999e0d63
2 changed files with 7 additions and 8 deletions

View File

@@ -98,7 +98,7 @@ exports.checkIn = async () => {
let reqOptions; let reqOptions;
await this.checkConfig(); await this.checkConfig();
// Check if there is an ID found, if not add the node to the server. If there was an ID, check in with the server to make sure it has the correct information // Check if there is an ID found, if not add the node to the server. If there was an ID, check in with the server to make sure it has the correct information
if (clientId === 0) { if (runningClientConfig.id === 0) {
// ID was not found in the config, creating a new node // ID was not found in the config, creating a new node
reqOptions = new requests.requestOptions("/nodes/newNode", "POST"); reqOptions = new requests.requestOptions("/nodes/newNode", "POST");
requests.sendHttpRequest(reqOptions, JSON.stringify(), (responseObject) => { requests.sendHttpRequest(reqOptions, JSON.stringify(), (responseObject) => {

View File

@@ -5,19 +5,18 @@ const log = new DebugBuilder("client", "httpRequests");
require('dotenv').config(); require('dotenv').config();
// Modules // Modules
const http = require("http"); const http = require("http");
const { nodeObject } = require("./recordHelper.js");
var runningClientConfig = new nodeObject({_id: process.env.CLIENT_ID, _ip: process.env.CLIENT_IP, _name: process.env.CLIENT_NAME, _port: process.env.CLIENT_PORT, _location: process.env.CLIENT_LOCATION, _nearbySystems: process.env.CLIENT_NEARBY_SYSTEMS, _online: process.env.CLIENT_ONLINE});
exports.requestOptions = class requestOptions { exports.requestOptions = class requestOptions {
constructor(path, method, hostname = undefined, headers = undefined, port = undefined) { constructor(path, method, hostname = undefined, headers = undefined, port = undefined) {
if (method === "POST"){ if (method === "POST"){
this.hostname = hostname ?? runningClientConfig.hostname this.hostname = hostname ?? process.env.SERVER_HOSTNAME ?? process.env.SERVER_IP;
this.path = path this.path = path;
this.port = port ?? runningClientConfig.port this.port = port ?? process.env.SERVER_PORT;
this.method = method this.method = method;
this.headers = headers ?? { this.headers = headers ?? {
'Content-Type': 'application/json', 'Content-Type': 'application/json',
} };
} }
} }
} }