2 Commits

Author SHA1 Message Date
Logan Cusano
2108a3b92b Improved error response for new node 2023-06-18 17:13:29 -04:00
Logan Cusano
960b801dd2 Working on initial startup for new clients 2023-06-18 16:36:38 -04:00
2 changed files with 3 additions and 2 deletions

View File

@@ -105,7 +105,7 @@ exports.checkIn = async () => {
if (!runningClientConfig?.id || runningClientConfig.id == null) { if (!runningClientConfig?.id || runningClientConfig.id == null) {
// ID was not found in the config, creating a new node // ID was not found in the config, creating a new node
reqOptions = new requestOptions("/nodes/newNode", "POST"); reqOptions = new requestOptions("/nodes/newNode", "POST");
sendHttpRequest(reqOptions, JSON.stringify(), (responseObject) => { sendHttpRequest(reqOptions, JSON.stringify({}), (responseObject) => {
// Update the client's ID if the server accepted it // Update the client's ID if the server accepted it
if (responseObject.statusCode === 202) { if (responseObject.statusCode === 202) {
runningClientConfig.id = responseObject.body.nodeId; runningClientConfig.id = responseObject.body.nodeId;
@@ -114,6 +114,7 @@ exports.checkIn = async () => {
if (responseObject.statusCode >= 300) { if (responseObject.statusCode >= 300) {
// Server threw an error // Server threw an error
log.DEBUG("HTTP Error: ", responseObject);
onHttpError(responseObject.statusCode); onHttpError(responseObject.statusCode);
} }

View File

@@ -25,7 +25,7 @@ exports.listAllNodes = async (req, res) => {
// Add a new node to the storage // Add a new node to the storage
exports.newNode = async (req, res) => { exports.newNode = async (req, res) => {
if (!req.body.name) return res.send(400) if (!req.body.name) return res.status(400).json("No name specified for new node");
try { try {
// Try to add the new user with defaults if missing options // Try to add the new user with defaults if missing options