From 66ee4809cab661b499463126eb8ab913f478ff4b Mon Sep 17 00:00:00 2001 From: Austin Hampton Date: Thu, 14 Aug 2025 11:23:42 -0400 Subject: [PATCH 01/36] style: Removed non helpful logs from tasks.js --- external/protobuf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/external/protobuf b/external/protobuf index a9b006bdd..fff909ea5 160000 --- a/external/protobuf +++ b/external/protobuf @@ -1 +1 @@ -Subproject commit a9b006bddd52e289029f16aa77b77e8e0033d9ee +Subproject commit fff909ea5104ca2104898516511ee03ee4505078 From 6767d06bf353fbfb5828530c4d00296418ae8324 Mon Sep 17 00:00:00 2001 From: Austin Hampton Date: Fri, 22 Aug 2025 09:36:55 -0400 Subject: [PATCH 02/36] fix: reverted protobuf to match devel (a9b006) --- external/protobuf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/external/protobuf b/external/protobuf index fff909ea5..a9b006bdd 160000 --- a/external/protobuf +++ b/external/protobuf @@ -1 +1 @@ -Subproject commit fff909ea5104ca2104898516511ee03ee4505078 +Subproject commit a9b006bddd52e289029f16aa77b77e8e0033d9ee From 679177ce7cec70eb793efe6e7fc01af78ac2189b Mon Sep 17 00:00:00 2001 From: Austin Hampton Date: Tue, 26 Aug 2025 12:53:37 -0400 Subject: [PATCH 03/36] refactor: Refactoered the user_router to have a first pass of standardized logging (needs more testing) --- core/database/foxx/api/user_router.js | 643 ++++++++++++++++++++++++-- 1 file changed, 615 insertions(+), 28 deletions(-) diff --git a/core/database/foxx/api/user_router.js b/core/database/foxx/api/user_router.js index 6738bf5b1..6c7c97575 100644 --- a/core/database/foxx/api/user_router.js +++ b/core/database/foxx/api/user_router.js @@ -1,5 +1,6 @@ "use strict"; +const getCallerLocation = require('./lib/util'); const createRouter = require("@arangodb/foxx/router"); const router = createRouter(); const joi = require("joi"); @@ -17,13 +18,22 @@ module.exports = router; router .get("/authn/password", function (req, res) { + let client = undefined; console.log("Running /authn/password"); try { - const client = g_lib.getUserFromClientID(req.queryParams.client); + client = g_lib.getUserFromClientID(req.queryParams.client); const is_verified = auth.verify(client.password, req.queryParams.pw); if (is_verified === false) { throw g_lib.ERR_AUTHN_FAILED; } + console.info( + "Client:",client?._id || "unknown", + "Correlation_ID:", "unknown", + "HTTP:","GET", + "Route:", "/authn/password", + "Status:", "Started", + "Desc:", "Authenticating user via password"); + //if ( client.password != req.queryParams.pw ) // throw g_lib.ERR_AUTHN_FAILED; @@ -32,7 +42,25 @@ router uid: client._id, authorized: true, }); + console.info( + "Client:",client?._id || "unknown", + "Correlation_ID:", "unknown", + "HTTP:","GET", + "Route:", "/authn/password", + "Status:", "Success", + "Desc:", "Authenticating user via password"); + + } catch (e) { + console.info( + "Client:", client?._id || "unknown", "|", + "Correlation_ID:", "unknown", "|", + "HTTP:","GET", "|", + "Route:", "/authn/password", "|", + "Status:", "Failure", "|", + "Desc:", "Authenticating user via password", "|", + "Err:", e.message || e, "|", + "Stack:", e.stack || "No Stack Trace"); g_lib.handleException(e, res); } }) @@ -43,17 +71,42 @@ router router .get("/authn/token", function (req, res) { + let user = undefined; try { - var user = g_db._query("for i in u filter i.access == @tok return i", { + user = g_db._query("for i in u filter i.access == @tok return i", { tok: req.queryParams.token, }); + console.info( + "Client:",user?._id || "unknown", "|", + "Correlation_ID:", "unknown", "|", + "HTTP:","GET", "|", + "Route:", "/authn/token", "|", + "Status:", "Started", "|", + "Desc:", "Authenticating user via access token"); + if (!user.hasNext()) throw g_lib.ERR_AUTHN_FAILED; res.send({ uid: user.next()._id, authorized: true, }); + console.info( + "Client:",user?._id || "unknown", "|", + "Correlation_ID:", "unknown", "|", + "HTTP:","GET", "|", + "Route:", "/authn/token", "|", + "Status:", "Success", "|", + "Desc:", "Authenticating user via access token"); } catch (e) { + console.info( + "Client:", user?._id || "unknown", "|", + "Correlation_ID:", "unknown", "|", + "HTTP:","GET", "|", + "Route:", "/authn/token", "|", + "Status:", "Failure", "|", + "Desc:", "Authenticating user via access token", "|", + "Err:", e.message || e, "|", + "Stack:", e.stack || "No Stack Trace"); g_lib.handleException(e, res); } }) @@ -63,6 +116,7 @@ router router .get("/create", function (req, res) { + let user = undefined; try { var result; @@ -120,9 +174,17 @@ router user_data.options = req.queryParams.options; } - var user = g_db.u.save(user_data, { + user = g_db.u.save(user_data, { returnNew: true, }); + console.info( + "Client:", user?._id || "unknown", "|", + "Correlation_ID:", "unknown", "|", + "HTTP:","GET", "|", + "Route:", "/create", "|", + "Status:", "Started", "|", + "Desc:", "Creating new user entry", "|"); + var root = g_db.c.save( { _key: "u_" + req.queryParams.uid + "_root", @@ -203,9 +265,25 @@ router result = [user.new]; }, }); - res.send(result); - } catch (e) { + console.info( + "Client:", user?._id || "unknown", "|", + "Correlation_ID:", "unknown", "|", + "HTTP:","GET", "|", + "Route:", "/create", "|", + "Status:", "Success", "|", + "Desc:", "Create new user entry", "|"); + + } catch (e) { + console.error( + "Client:", user?._id || "unknown", "|", + "Correlation_ID:", "unknown", "|", + "HTTP:","GET", "|", + "Route:", "/create", "|", + "Status:", "Failure", "|", + "Desc:", "Create new user entry", "|", + "Err:", e.message || e, "|", + "Stack:", e.stack || "No Stack Trace"); g_lib.handleException(e, res); } }) @@ -226,6 +304,7 @@ router router .get("/update", function (req, res) { + let client = undefined; try { var result; @@ -235,9 +314,15 @@ router write: ["u", "admin"], }, action: function () { - const client = g_lib.getUserFromClientID(req.queryParams.client); + client = g_lib.getUserFromClientID(req.queryParams.client); var user_id; - + console.info( + "Client:", client?._id || "unknown", "|", + "Correlation_ID:", "unknown", "|", + "HTTP:","GET", "|", + "Route:", "/update", "|", + "Status:", "Started", "|", + "Desc:", "Updating user information", "|"); if (req.queryParams.subject) { user_id = req.queryParams.subject; if (!g_db.u.exists(user_id)) @@ -299,7 +384,24 @@ router }); res.send(result); + console.info( + "Client:", client?._id || "unknown", "|", + "Correlation_ID:", "unknown", "|", + "HTTP:","GET", "|", + "Route:", "/update", "|", + "Status:", "Success", "|", + "Desc:", "Updating user information", "|"); + } catch (e) { + console.error( + "Client:", client?._id || "unknown", "|", + "Correlation_ID:", "unknown", "|", + "HTTP:","GET", "|", + "Route:", "/update", "|", + "Status:", "Failure", "|", + "Desc:", "Updating user information", "|", + "Err:", e.message || e, "|", + "Stack:", e.stack || "No Stack Trace"); g_lib.handleException(e, res); } }) @@ -315,14 +417,22 @@ router router .get("/find/by_uuids", function (req, res) { + let user = undefined; try { // Convert UUIDs to DB _ids var uuids = []; for (var i in req.queryParams.uuids) { uuids.push("uuid/" + req.queryParams.uuids[i]); } - - var user = g_lib.findUserFromUUIDs(uuids); + + user = g_lib.findUserFromUUIDs(uuids); + console.info( + "Client:", user?._id || "unknown", "|", + "Correlation_ID:", "unknown", "|", + "HTTP:","GET", "|", + "Route:", "/find/by_uuids", "|", + "Status:", "Started", "|", + "Desc:", "Find a user from list of UUIDs", "|"); var idents = g_db ._query("for v in 1..1 outbound @user ident return v._key", { @@ -341,7 +451,24 @@ router delete user.name; res.send([user]); + console.info( + "Client:", user?._id || "unknown", "|", + "Correlation_ID:", "unknown", "|", + "HTTP:","GET", "|", + "Route:", "/find/by_uuids", "|", + "Status:", "Success", "|", + "Desc:", "Find a user from list of UUIDs", "|"); + } catch (e) { + console.error( + "Client:", user?._id || "unknown", "|", + "Correlation_ID:", "unknown", "|", + "HTTP:","GET", "|", + "Route:", "/find/by_uuids", "|", + "Status:", "Failure", "|", + "Desc:", "Find a user from list of UUIDs", "|", + "Err:", e.message || e, "|", + "Stack:", e.stack || "No Stack Trace"); g_lib.handleException(e, res); } }) @@ -351,8 +478,17 @@ router router .get("/find/by_name_uid", function (req, res) { + let name = undefined; try { - var name = req.queryParams.name_uid.trim(); + name = req.queryParams.name_uid.trim(); + console.info( + "Client:", name || "unknown", "|", + "Correlation_ID:", "unknown", "|", + "HTTP:","GET", "|", + "Route:", "/find/by_name_uid", "|", + "Status:", "Started", "|", + "Desc:", "Find a user from list of UUIDs", "|"); + if (name.length < 2) throw [g_lib.ERR_INVALID_PARAM, "Input is too short for name/uid search."]; else if (name.length < 3) name = " " + name + " "; // Pad to allow matches for very short first/last names (i.e. Bo, Li, Xi) @@ -384,7 +520,25 @@ router }); res.send(result); + console.info( + "Client:", name || "unknown", "|", + "Correlation_ID:", "unknown", "|", + "HTTP:","GET", "|", + "Route:", "/find/by_name_uid", "|", + "Status:", "Success", "|", + "Desc:", "Find users matching partial name and/or uid", "|"); + + } catch (e) { + console.error( + "Client:", name || "unknown", "|", + "Correlation_ID:", "unknown", "|", + "HTTP:","GET", "|", + "Route:", "/find/by_name_uid", "|", + "Status:", "Failure", "|", + "Desc:", "Find users matching partial name and/or uid", "|", + "Err:", e.message || e, "|", + "Stack:", e.stack || "No Stack Trace"); g_lib.handleException(e, res); } }) @@ -396,6 +550,7 @@ router router .get("/keys/set", function (req, res) { + let client = undefined; try { g_db._executeTransaction({ collections: { @@ -403,7 +558,15 @@ router write: ["u"], }, action: function () { - const client = g_lib.getUserFromClientID(req.queryParams.client); + client = g_lib.getUserFromClientID(req.queryParams.client); + console.info( + "Client:", client?._id || "unknown", "|", + "Correlation_ID:", "unknown", "|", + "HTTP:","GET", "|", + "Route:", "/keys/set", "|", + "Status:", "Started", "|", + "Desc:", "Set user public and private keys", "|"); + var user_id; if (req.queryParams.subject) { @@ -424,7 +587,25 @@ router }); }, }); + console.info( + "Client:", client?._id || "unknown", "|", + "Correlation_ID:", "unknown", "|", + "HTTP:","GET", "|", + "Route:", "/keys/set", "|", + "Status:", "Success", "|", + "Desc:", "Set user public and private keys", "|"); + + } catch (e) { + console.error( + "Client:", client?._id || "unknown", "|", + "Correlation_ID:", "unknown", "|", + "HTTP:","GET", "|", + "Route:", "/keys/set", "|", + "Status:", "Failure", "|", + "Desc:", "Set user public and private keys", "|", + "Err:", e.message || e, "|", + "Stack:", e.stack || "No Stack Trace"); g_lib.handleException(e, res); } }) @@ -437,6 +618,7 @@ router router .get("/keys/clear", function (req, res) { + let client = undefined; try { g_db._executeTransaction({ collections: { @@ -444,7 +626,14 @@ router write: ["u"], }, action: function () { - const client = g_lib.getUserFromClientID(req.queryParams.client); + client = g_lib.getUserFromClientID(req.queryParams.client); + console.info( + "Client:", client?._id || "unknown", "|", + "Correlation_ID:", "unknown", "|", + "HTTP:","GET", "|", + "Route:", "/keys/set", "|", + "Status:", "Started", "|", + "Desc:", "Clear user public and private keys", "|"); var user_id; if (req.queryParams.subject) { @@ -465,7 +654,23 @@ router }); }, }); + console.info( + "Client:", client?._id || "unknown", "|", + "Correlation_ID:", "unknown", "|", + "HTTP:","GET", "|", + "Route:", "/keys/set", "|", + "Status:", "Success", "|", + "Desc:", "Clear user public and private keys", "|"); } catch (e) { + console.error( + "Client:", client?._id || "unknown", "|", + "Correlation_ID:", "unknown", "|", + "HTTP:","GET", "|", + "Route:", "/keys/set", "|", + "Status:", "Failure", "|", + "Desc:", "Clear user public and private keys", "|", + "Err:", e.message || e, "|", + "Stack:", e.stack || "No Stack Trace"); g_lib.handleException(e, res); } }) @@ -476,9 +681,8 @@ router router .get("/keys/get", function (req, res) { + let user = undefined; try { - var user; - if (req.queryParams.subject) { if (!g_db.u.exists(req.queryParams.subject)) throw [ @@ -489,16 +693,33 @@ router user = g_db.u.document({ _id: req.queryParams.subject, }); + console.info( + "Client:", user?._id || "unknown", "|", + "Correlation_ID:", "unknown", "|", + "HTTP:","GET", "|", + "Route:", "/keys/get", "|", + "Status:", "Started", "|", + "Desc:", "Get user public and private keys", "|"); + } else { user = g_lib.getUserFromClientID(req.queryParams.client); } if (!user.pub_key || !user.priv_key) + { res.send([ { uid: user._id, }, ]); + console.info( + "Client:", user?._id || "unknown", "|", + "Correlation_ID:", "unknown", "|", + "HTTP:","GET", "|", + "Route:", "/keys/get", "|", + "Status:", "Success", "|", + "Desc:", "Get user public and private keys", "|"); + } else res.send([ { @@ -507,7 +728,24 @@ router priv_key: user.priv_key, }, ]); + console.info( + "Client:", user?._id || "unknown", "|", + "Correlation_ID:", "unknown", "|", + "HTTP:","GET", "|", + "Route:", "/keys/get", "|", + "Status:", "Success", "|", + "Desc:", "Get user public and private keys", "|"); + } catch (e) { + console.error( + "Client:", user?._id || "unknown", "|", + "Correlation_ID:", "unknown", "|", + "HTTP:","GET", "|", + "Route:", "/keys/get", "|", + "Status:", "Failure", "|", + "Desc:", "Get user public and private keys", "|", + "Err:", e.message || e, "|", + "Stack:", e.stack || "No Stack Trace"); g_lib.handleException(e, res); } }) @@ -518,10 +756,35 @@ router router .get("/find/by_pub_key", function (req, res) { + let uid = undefined; try { - var uid = g_lib.uidFromPubKey(req.queryParams.pub_key); + uid = g_lib.uidFromPubKey(req.queryParams.pub_key); + console.info( + "Client:", uid || "unknown", "|", + "Correlation_ID:", "unknown", "|", + "HTTP:","GET", "|", + "Route:", "/find/by_pub_key", "|", + "Status:", "Started", "|", + "Desc:", "Find a user by public key", "|"); + res.send(uid); + console.info( + "Client:", uid || "unknown", "|", + "Correlation_ID:", "unknown", "|", + "HTTP:","GET", "|", + "Route:", "/find/by_pub_key", "|", + "Status:", "Success", "|", + "Desc:", "Find a user by public key", "|"); } catch (e) { + console.error( + "Client:", uid || "unknown", "|", + "Correlation_ID:", "unknown", "|", + "HTTP:","GET", "|", + "Route:", "/find/by_pub_key", "|", + "Status:", "Failure", "|", + "Desc:", "Find a user by public key", "|", + "Err:", e.message || e, "|", + "Stack:", e.stack || "No Stack Trace"); g_lib.handleException(e, res); } }) @@ -531,6 +794,7 @@ router router .get("/token/set", function (req, res) { + let client = undefined; try { g_db._executeTransaction({ collections: { @@ -538,7 +802,15 @@ router write: ["u", "globus_coll", "globus_token"], }, action: function () { - const client = g_lib.getUserFromClientID(req.queryParams.client); + client = g_lib.getUserFromClientID(req.queryParams.client); + console.info( + "Client:", client?._id || "unknown", "|", + "Correlation_ID:", "unknown", "|", + "HTTP:","GET", "|", + "Route:", "/token/set", "|", + "Status:", "Started", "|", + "Desc:", "Setting user token", "|"); + var user_id; let user_doc; @@ -652,10 +924,26 @@ router }); break; } + console.info( + "Client:", client?._id || "unknown", "|", + "Correlation_ID:", "unknown", "|", + "HTTP:","GET", "|", + "Route:", "/token/set", "|", + "Status:", "Success", "|", + "Desc:", "Setting user token", "|"); } }, }); } catch (e) { + console.error( + "Client:", client?._id || "unknown", "|", + "Correlation_ID:", "unknown", "|", + "HTTP:","GET", "|", + "Route:", "/token/set", "|", + "Status:", "Failure", "|", + "Desc:", "Setting user token", "|", + "Err:", e.message || e, "|", + "Stack:", e.stack || "No Stack Trace"); g_lib.handleException(e, res); } }) @@ -687,12 +975,12 @@ router router .get("/token/get", function (req, res) { + let user = undefined; try { const collection_token = UserToken.validateRequestParams(req.queryParams); // TODO: collection type determines logic when mapped vs HA const { collection_id, collection_type } = req.queryParams; - var user; if (req.queryParams.subject) { if (!g_db.u.exists(req.queryParams.subject)) @@ -707,6 +995,15 @@ router } else { user = g_lib.getUserFromClientID(req.queryParams.client); } + + console.info( + "Client:",user?._id || "unknown", "|", + "Correlation_ID:", "unknown", "|", + "HTTP:","GET", "|", + "Route:", "usr/token/get/", "|", + "Status:", "Started", "|", + "Desc:", "Getting User Token"); + const user_token = new UserToken({ user_id: user._id, @@ -725,7 +1022,23 @@ router ); res.send(result); + console.info( + "Client:", user?._id || "unknown", "|", + "Correlation_ID:", "unknown", "|", + "HTTP:","GET", "|", + "Route:", "usr/token/get/", "|", + "Status:", "Success", "|", + "Desc:", "Getting User Token"); } catch (e) { + console.error( + "Client:", user?._id || "unknown", "|", + "Correlation_ID:", "unknown", "|", + "HTTP:","GET", "|", + "Route:", "usr/token/get/", "|", + "Status:", "Failure", "|", + "Desc:", "Getting User Token", "|", + "Err:", e.message || e, "|", + "Stack:", e.stack || "No Stack Trace"); g_lib.handleException(e, res); } }) @@ -746,9 +1059,8 @@ router router .get("/token/get/access", function (req, res) { + let user = undefined; try { - var user; - if (req.queryParams.subject) { if (!g_db.u.exists(req.queryParams.subject)) throw [ @@ -761,11 +1073,34 @@ router } else { user = g_lib.getUserFromClientID(req.queryParams.client); } + console.info( + "Client:", user?._id || "unknown", "|", + "Correlation_ID:", "unknown", "|", + "HTTP:","GET", "|", + "Route:", "/token/get/access", "|", + "Status:", "Started", "|", + "Desc:", "Getting User Access Token"); if (!user.access) throw [g_lib.ERR_NOT_FOUND, "No access token found"]; res.send(user.access); + console.info( + "Client:", user?._id || "unknown", "|", + "Correlation_ID:", "unknown", "|", + "HTTP:","GET", "|", + "Route:", "/token/get/access", "|", + "Status:", "Success", "|", + "Desc:", "Getting User Access Token"); } catch (e) { + console.error( + "Client:", user?._id || "unknown", "|", + "Correlation_ID:", "unknown", "|", + "HTTP:","GET", "|", + "Route:", "/token/get/access", "|", + "Status:", "Failure", "|", + "Desc:", "Getting User Access Token", "|", + "Err:", e.message || e, "|", + "Stack:", e.stack || "No Stack Trace"); g_lib.handleException(e, res); } }) @@ -776,8 +1111,16 @@ router router .get("/token/get/expiring", function (req, res) { + let user = undefined; try { //console.log("exp:",(Date.now()/1000) + req.queryParams.expires_in); + console.info( + "Client:", user?._id || "unknown", "|", + "Correlation_ID:", "unknown", "|", + "HTTP:","GET", "|", + "Route:", "/token/get/expiring", "|", + "Status:", "Started", "|", + "Desc:", "Getting expiring user access token"); var results = g_db._query( "for i in u filter i.expiration != Null && i.expiration < @exp return {id:i._id,access:i.access,refresh:i.refresh,expiration:i.expiration}", @@ -786,7 +1129,23 @@ router }, ); res.send(results); + console.info( + "Client:", user?._id || "unknown", "|", + "Correlation_ID:", "unknown", "|", + "HTTP:","GET", "|", + "Route:", "/token/get/expiring", "|", + "Status:", "Success", "|", + "Desc:", "Getting expiring user access token"); } catch (e) { + console.error( + "Client:", user?._id || "unknown", "|", + "Correlation_ID:", "unknown", "|", + "HTTP:","GET", "|", + "Route:", "/token/get/expiring", "|", + "Status:", "Failure", "|", + "Desc:", "Getting expiring user access token", "|", + "Err:", e.message || e, "|", + "Stack:", e.stack || "No Stack Trace"); g_lib.handleException(e, res); } }) @@ -797,8 +1156,16 @@ router router .get("/view", function (req, res) { + let client = undefined; try { - var client = g_lib.getUserFromClientID_noexcept(req.queryParams.client); + client = g_lib.getUserFromClientID_noexcept(req.queryParams.client); + console.info( + "Client:", client?._id || "unknown", "|", + "Correlation_ID:", "unknown", "|", + "HTTP:","GET", "|", + "Route:", "/view", "|", + "Status:", "Started", "|", + "Desc:", "View User Information"); var user, det_ok = false; @@ -879,8 +1246,25 @@ router delete user.refresh; res.send([user]); + console.info( + "Client:", client?._id || "unknown", "|", + "Correlation_ID:", "unknown", "|", + "HTTP:","GET", "|", + "Route:", "/view", "|", + "Status:", "Success", "|", + "Desc:", "View User Information"); + } catch (e) { g_lib.handleException(e, res); + console.error( + "Client:", client?._id || "unknown", "|", + "Correlation_ID:", "unknown", "|", + "HTTP:","GET", "|", + "Route:", "/view", "|", + "Status:", "Failure", "|", + "Desc:", "View User Information", "|", + "Err:", e.message || e, "|", + "Stack:", e.stack || "No Stack Trace"); } }) .queryParam("client", joi.string().required(), "Client ID") @@ -891,8 +1275,17 @@ router router .get("/list/all", function (req, res) { + var client = undefined; var qry = "for i in u sort i.name_last, i.name_first"; var result; + console.info( + "Client:", client?._id || "unknown", "|", + "Correlation_ID:", "unknown", "|", + "HTTP:","GET", "|", + "Route:", "/list/all", "|", + "Status:", "Started", "|", + "Desc:", "List all users"); + if (req.queryParams.offset != undefined && req.queryParams.count != undefined) { qry += @@ -924,6 +1317,13 @@ router } res.send(result); + console.info( + "Client:", client?._id || "unknown", "|", + "Correlation_ID:", "unknown", "|", + "HTTP:","GET", "|", + "Route:", "/list/all", "|", + "Status:", "Success", "|", + "Desc:", "List all users"); }) .queryParam("offset", joi.number().optional(), "Offset") .queryParam("count", joi.number().optional(), "Count") @@ -934,6 +1334,14 @@ router .get("/list/collab", function (req, res) { var result, client = g_lib.getUserFromClientID(req.queryParams.client); + console.info( + "Client:", client?._id || "unknown", "|", + "Correlation_ID:", "unknown", "|", + "HTTP:","GET", "|", + "Route:", "/list/collab", "|", + "Status:", "Started", "|", + "Desc:", "List collaborators of client"); + var qry = "for x in union_distinct((for v in 2..2 any @user owner, member, acl filter is_same_collection('u',v) return" + " distinct { uid: v._id, name_last: v.name_last, name_first: v.name_first }),(for v in 3..3 inbound @user member, outbound owner, outbound admin" + @@ -974,6 +1382,14 @@ router } res.send(result); + console.info( + "Client:", client?._id || "unknown", "|", + "Correlation_ID:", "unknown", "|", + "HTTP:","GET", "|", + "Route:", "/list/collab", "|", + "Status:", "Success", "|", + "Desc:", "List collaborators of client"); + //res.send( g_db._query( "for x in union_distinct((for v in 2..2 any @user owner, member, acl filter is_same_collection('u',v) return distinct { uid: v._id, name: v.name }),(for v in 3..3 inbound @user member, outbound owner, outbound admin filter is_same_collection('u',v) return distinct { uid: v._id, name: v.name }),(for v in 2..2 inbound @user owner, outbound admin filter is_same_collection('u',v) return distinct { uid: v._id, name: v.name })) return x", { user: client._id })); }) .queryParam("client", joi.string().required(), "Client ID") @@ -1015,6 +1431,13 @@ router action: function () { const client = g_lib.getUserFromClientID(req.queryParams.client); var user_id; + console.info( + "Client:", client?._id || "unknown", "|", + "Correlation_ID:", "unknown", "|", + "HTTP:","GET", "|", + "Route:", "/delete", "|", + "Status:", "Started", "|", + "Desc:", "Remove existing user entry"); if (req.queryParams.subject) { user_id = req.queryParams.subject; @@ -1081,7 +1504,23 @@ router g_graph.u.remove(user_id); }, }); + console.info( + "Client:", client?._id || "unknown", "|", + "Correlation_ID:", "unknown", "|", + "HTTP:","GET", "|", + "Route:", "/delete", "|", + "Status:", "Success", "|", + "Desc:", "Remove existing user entry"); } catch (e) { + console.error( + "Client:", client?._id || "unknown", "|", + "Correlation_ID:", "unknown", "|", + "HTTP:","GET", "|", + "Route:", "/delete", "|", + "Status:", "Failure", "|", + "Desc:", "Remove existing user entry", "|", + "Err:", e.message || e, "|", + "Stack:", e.stack || "No Stack Trace"); g_lib.handleException(e, res); } }) @@ -1092,8 +1531,18 @@ router router .get("/ident/list", function (req, res) { + let client = undefined; try { - var client = g_lib.getUserFromClientID(req.queryParams.client); + client = g_lib.getUserFromClientID(req.queryParams.client); + console.info( + "Client:", client?._id || "unknown", "|", + "Correlation_ID:", "unknown", "|", + "HTTP:","GET", "|", + "Route:", "/ident/list", "|", + "Status:", "Started", "|", + "Desc:", "List user linked IDs"); + + if (req.queryParams.subject) { if (!g_db.u.exists(req.queryParams.subject)) throw [ @@ -1108,14 +1557,39 @@ router client: subject._id, }), ); + console.info( + "Client:", client?._id || "unknown", "|", + "Correlation_ID:", "unknown", "|", + "HTTP:","GET", "|", + "Route:", "/ident/list", "|", + "Status:", "Success", "|", + "Desc:", "List user linked IDs"); + + } else { - res.send( - g_db._query("for v in 1..1 outbound @client ident return v._key", { + res.send(g_db._query("for v in 1..1 outbound @client ident return v._key", { client: client._id, }), ); + console.info( + "Client:", client?._id || "unknown", "|", + "Correlation_ID:", "unknown", "|", + "HTTP:","GET", "|", + "Route:", "/ident/list", "|", + "Status:", "Success", "|", + "Desc:", "List user linked IDs"); + } } catch (e) { + console.error( + "Client:", client?._id || "unknown", "|", + "Correlation_ID:", "unknown", "|", + "HTTP:","GET", "|", + "Route:", "/ident/list", "|", + "Status:", "Failure", "|", + "Desc:", "List user linked IDs", "|", + "Err:", e.message || e, "|", + "Stack:", e.stack || "No Stack Trace"); g_lib.handleException(e, res); } }) @@ -1125,6 +1599,7 @@ router router .get("/ident/add", function (req, res) { + let client = undefined; try { g_db._executeTransaction({ collections: { @@ -1132,7 +1607,14 @@ router write: ["uuid", "accn", "ident"], }, action: function () { - const client = g_lib.getUserFromClientID(req.queryParams.client); + client = g_lib.getUserFromClientID(req.queryParams.client); + console.info( + "Client:", client?._id || "unknown", "|", + "Correlation_ID:", "unknown", "|", + "HTTP:","GET", "|", + "Route:", "/ident/add", "|", + "Status:", "Started", "|", + "Desc:", "Add new linked identity"); var id; if (g_lib.isUUID(req.queryParams.ident)) { @@ -1141,6 +1623,13 @@ router _id: "uuid/" + req.queryParams.ident, }) ) + console.info( + "Client:", client?._id || "unknown", "|", + "Correlation_ID:", "unknown", "|", + "HTTP:","GET", "|", + "Route:", "/ident/add", "|", + "Status:", "Success", "|", + "Desc:", "Add new linked identity"); return; id = g_db.uuid.save( { @@ -1168,6 +1657,13 @@ router }, ); } + console.info( + "Client:", client?._id || "unknown", "|", + "Correlation_ID:", "unknown", "|", + "HTTP:","GET", "|", + "Route:", "/ident/add", "|", + "Status:", "Success", "|", + "Desc:", "Add new linked identity"); return; } else { var accn = { @@ -1209,7 +1705,23 @@ router } }, }); + console.info( + "Client:", client?._id || "unknown", "|", + "Correlation_ID:", "unknown", "|", + "HTTP:","GET", "|", + "Route:", "/ident/add", "|", + "Status:", "Success", "|", + "Desc:", "Add new linked identity"); } catch (e) { + console.error( + "Client:", client?._id || "unknown", "|", + "Correlation_ID:", "unknown", "|", + "HTTP:","GET", "|", + "Route:", "/ident/add", "|", + "Status:", "Failure", "|", + "Desc:", "Add new linked identity", "|", + "Err:", e.message || e, "|", + "Stack:", e.stack || "No Stack Trace"); g_lib.handleException(e, res); } }) @@ -1225,6 +1737,7 @@ router router .get("/ident/remove", function (req, res) { + let client = undefined; try { g_db._executeTransaction({ collections: { @@ -1232,9 +1745,15 @@ router write: ["uuid", "accn", "ident"], }, action: function () { - const client = g_lib.getUserFromClientID(req.queryParams.client); + client = g_lib.getUserFromClientID(req.queryParams.client); const owner = g_lib.getUserFromClientID(req.queryParams.ident); - + console.info( + "Client:", client?._id || "unknown", "|", + "Correlation_ID:", "unknown", "|", + "HTTP:","GET", "|", + "Route:", "/ident/remove", "|", + "Status:", "Started", "|", + "Desc:", "Remove linked identity from user account"); g_lib.ensureAdminPermUser(client, owner._id); if (g_lib.isUUID(req.queryParams.ident)) { @@ -1248,7 +1767,24 @@ router ]; }, }); + console.info( + "Client:", client?._id || "unknown", "|", + "Correlation_ID:", "unknown", "|", + "HTTP:","GET", "|", + "Route:", "/ident/remove", "|", + "Status:", "Success", "|", + "Desc:", "Remove linked identity from user account"); + } catch (e) { + console.error( + "Client:", client?._id || "unknown", "|", + "Correlation_ID:", "unknown", "|", + "HTTP:","GET", "|", + "Route:", "/ident/remove", "|", + "Status:", "Failure", "|", + "Desc:", "Remove linked identity from user account", "|", + "Err:", e.message || e, "|", + "Stack:", e.stack || "No Stack Trace"); g_lib.handleException(e, res); } }) @@ -1259,10 +1795,35 @@ router router .get("/ep/get", function (req, res) { + let client = undefined; try { - const client = g_lib.getUserFromClientID(req.queryParams.client); + client = g_lib.getUserFromClientID(req.queryParams.client); + console.info( + "Client:", client?._id || "unknown", "|", + "Correlation_ID:", "unknown", "|", + "HTTP:","GET", "|", + "Route:", "/ep/get", "|", + "Status:", "Started", "|", + "Desc:", "Get recent end-points"); + res.send(client.eps ? client.eps : []); + console.info( + "Client:", client?._id || "unknown", "|", + "Correlation_ID:", "unknown", "|", + "HTTP:","GET", "|", + "Route:", "/ep/get", "|", + "Status:", "Success", "|", + "Desc:", "Get recent end-points"); } catch (e) { + console.error( + "Client:", client?._id || "unknown", "|", + "Correlation_ID:", "unknown", "|", + "HTTP:","GET", "|", + "Route:", "/ep/get", "|", + "Status:", "Failure", "|", + "Desc:", "Get recent end-points", "|", + "Err:", e.message || e, "|", + "Stack:", e.stack || "No Stack Trace"); g_lib.handleException(e, res); } }) @@ -1272,8 +1833,17 @@ router router .get("/ep/set", function (req, res) { + let client = undefined; try { - const client = g_lib.getUserFromClientID(req.queryParams.client); + client = g_lib.getUserFromClientID(req.queryParams.client); + console.info( + "Client:", client?._id || "unknown", "|", + "Correlation_ID:", "unknown", "|", + "HTTP:","GET", "|", + "Route:", "/ep/set", "|", + "Status:", "Started", "|", + "Desc:", "Set recent end-points"); + g_db._update( client._id, { @@ -1283,7 +1853,24 @@ router keepNull: false, }, ); + console.info( + "Client:", client?._id || "unknown", "|", + "Correlation_ID:", "unknown", "|", + "HTTP:","GET", "|", + "Route:", "/ep/set", "|", + "Status:", "Success", "|", + "Desc:", "Set recent end-points"); + } catch (e) { + console.error( + "Client:", client?._id || "unknown", "|", + "Correlation_ID:", "unknown", "|", + "HTTP:","GET", "|", + "Route:", "/ep/set", "|", + "Status:", "Failure", "|", + "Desc:", "Set recent end-points", "|", + "Err:", e.message || e, "|", + "Stack:", e.stack || "No Stack Trace"); g_lib.handleException(e, res); } }) From d23cfa6962da3ec4ba9ebb7d95d6222d466687fa Mon Sep 17 00:00:00 2001 From: Austin Hampton Date: Wed, 27 Aug 2025 07:51:57 -0400 Subject: [PATCH 04/36] style:Fomratted with prettier --- core/database/foxx/api/user_router.js | 1970 ++++++++++++++++++------- 1 file changed, 1446 insertions(+), 524 deletions(-) diff --git a/core/database/foxx/api/user_router.js b/core/database/foxx/api/user_router.js index 6c7c97575..94788df21 100644 --- a/core/database/foxx/api/user_router.js +++ b/core/database/foxx/api/user_router.js @@ -1,6 +1,5 @@ "use strict"; -const getCallerLocation = require('./lib/util'); const createRouter = require("@arangodb/foxx/router"); const router = createRouter(); const joi = require("joi"); @@ -26,14 +25,20 @@ router if (is_verified === false) { throw g_lib.ERR_AUTHN_FAILED; } - console.info( - "Client:",client?._id || "unknown", - "Correlation_ID:", "unknown", - "HTTP:","GET", - "Route:", "/authn/password", - "Status:", "Started", - "Desc:", "Authenticating user via password"); - + console.info( + "Client:", + client?._id || "unknown", + "Correlation_ID:", + "unknown", + "HTTP:", + "GET", + "Route:", + "/authn/password", + "Status:", + "Started", + "Desc:", + "Authenticating user via password", + ); //if ( client.password != req.queryParams.pw ) // throw g_lib.ERR_AUTHN_FAILED; @@ -42,25 +47,46 @@ router uid: client._id, authorized: true, }); - console.info( - "Client:",client?._id || "unknown", - "Correlation_ID:", "unknown", - "HTTP:","GET", - "Route:", "/authn/password", - "Status:", "Success", - "Desc:", "Authenticating user via password"); - - + console.info( + "Client:", + client?._id || "unknown", + "Correlation_ID:", + "unknown", + "HTTP:", + "GET", + "Route:", + "/authn/password", + "Status:", + "Success", + "Desc:", + "Authenticating user via password", + ); } catch (e) { console.info( - "Client:", client?._id || "unknown", "|", - "Correlation_ID:", "unknown", "|", - "HTTP:","GET", "|", - "Route:", "/authn/password", "|", - "Status:", "Failure", "|", - "Desc:", "Authenticating user via password", "|", - "Err:", e.message || e, "|", - "Stack:", e.stack || "No Stack Trace"); + "Client:", + client?._id || "unknown", + "|", + "Correlation_ID:", + "unknown", + "|", + "HTTP:", + "GET", + "|", + "Route:", + "/authn/password", + "|", + "Status:", + "Failure", + "|", + "Desc:", + "Authenticating user via password", + "|", + "Err:", + e.message || e, + "|", + "Stack:", + e.stack || "No Stack Trace", + ); g_lib.handleException(e, res); } }) @@ -76,13 +102,25 @@ router user = g_db._query("for i in u filter i.access == @tok return i", { tok: req.queryParams.token, }); - console.info( - "Client:",user?._id || "unknown", "|", - "Correlation_ID:", "unknown", "|", - "HTTP:","GET", "|", - "Route:", "/authn/token", "|", - "Status:", "Started", "|", - "Desc:", "Authenticating user via access token"); + console.info( + "Client:", + user?._id || "unknown", + "|", + "Correlation_ID:", + "unknown", + "|", + "HTTP:", + "GET", + "|", + "Route:", + "/authn/token", + "|", + "Status:", + "Started", + "|", + "Desc:", + "Authenticating user via access token", + ); if (!user.hasNext()) throw g_lib.ERR_AUTHN_FAILED; @@ -90,23 +128,51 @@ router uid: user.next()._id, authorized: true, }); - console.info( - "Client:",user?._id || "unknown", "|", - "Correlation_ID:", "unknown", "|", - "HTTP:","GET", "|", - "Route:", "/authn/token", "|", - "Status:", "Success", "|", - "Desc:", "Authenticating user via access token"); + console.info( + "Client:", + user?._id || "unknown", + "|", + "Correlation_ID:", + "unknown", + "|", + "HTTP:", + "GET", + "|", + "Route:", + "/authn/token", + "|", + "Status:", + "Success", + "|", + "Desc:", + "Authenticating user via access token", + ); } catch (e) { console.info( - "Client:", user?._id || "unknown", "|", - "Correlation_ID:", "unknown", "|", - "HTTP:","GET", "|", - "Route:", "/authn/token", "|", - "Status:", "Failure", "|", - "Desc:", "Authenticating user via access token", "|", - "Err:", e.message || e, "|", - "Stack:", e.stack || "No Stack Trace"); + "Client:", + user?._id || "unknown", + "|", + "Correlation_ID:", + "unknown", + "|", + "HTTP:", + "GET", + "|", + "Route:", + "/authn/token", + "|", + "Status:", + "Failure", + "|", + "Desc:", + "Authenticating user via access token", + "|", + "Err:", + e.message || e, + "|", + "Stack:", + e.stack || "No Stack Trace", + ); g_lib.handleException(e, res); } }) @@ -178,13 +244,26 @@ router returnNew: true, }); console.info( - "Client:", user?._id || "unknown", "|", - "Correlation_ID:", "unknown", "|", - "HTTP:","GET", "|", - "Route:", "/create", "|", - "Status:", "Started", "|", - "Desc:", "Creating new user entry", "|"); - + "Client:", + user?._id || "unknown", + "|", + "Correlation_ID:", + "unknown", + "|", + "HTTP:", + "GET", + "|", + "Route:", + "/create", + "|", + "Status:", + "Started", + "|", + "Desc:", + "Creating new user entry", + "|", + ); + var root = g_db.c.save( { _key: "u_" + req.queryParams.uid + "_root", @@ -267,23 +346,51 @@ router }); res.send(result); console.info( - "Client:", user?._id || "unknown", "|", - "Correlation_ID:", "unknown", "|", - "HTTP:","GET", "|", - "Route:", "/create", "|", - "Status:", "Success", "|", - "Desc:", "Create new user entry", "|"); - - } catch (e) { + "Client:", + user?._id || "unknown", + "|", + "Correlation_ID:", + "unknown", + "|", + "HTTP:", + "GET", + "|", + "Route:", + "/create", + "|", + "Status:", + "Success", + "|", + "Desc:", + "Create new user entry", + "|", + ); + } catch (e) { console.error( - "Client:", user?._id || "unknown", "|", - "Correlation_ID:", "unknown", "|", - "HTTP:","GET", "|", - "Route:", "/create", "|", - "Status:", "Failure", "|", - "Desc:", "Create new user entry", "|", - "Err:", e.message || e, "|", - "Stack:", e.stack || "No Stack Trace"); + "Client:", + user?._id || "unknown", + "|", + "Correlation_ID:", + "unknown", + "|", + "HTTP:", + "GET", + "|", + "Route:", + "/create", + "|", + "Status:", + "Failure", + "|", + "Desc:", + "Create new user entry", + "|", + "Err:", + e.message || e, + "|", + "Stack:", + e.stack || "No Stack Trace", + ); g_lib.handleException(e, res); } }) @@ -317,12 +424,25 @@ router client = g_lib.getUserFromClientID(req.queryParams.client); var user_id; console.info( - "Client:", client?._id || "unknown", "|", - "Correlation_ID:", "unknown", "|", - "HTTP:","GET", "|", - "Route:", "/update", "|", - "Status:", "Started", "|", - "Desc:", "Updating user information", "|"); + "Client:", + client?._id || "unknown", + "|", + "Correlation_ID:", + "unknown", + "|", + "HTTP:", + "GET", + "|", + "Route:", + "/update", + "|", + "Status:", + "Started", + "|", + "Desc:", + "Updating user information", + "|", + ); if (req.queryParams.subject) { user_id = req.queryParams.subject; if (!g_db.u.exists(user_id)) @@ -385,23 +505,51 @@ router res.send(result); console.info( - "Client:", client?._id || "unknown", "|", - "Correlation_ID:", "unknown", "|", - "HTTP:","GET", "|", - "Route:", "/update", "|", - "Status:", "Success", "|", - "Desc:", "Updating user information", "|"); - + "Client:", + client?._id || "unknown", + "|", + "Correlation_ID:", + "unknown", + "|", + "HTTP:", + "GET", + "|", + "Route:", + "/update", + "|", + "Status:", + "Success", + "|", + "Desc:", + "Updating user information", + "|", + ); } catch (e) { console.error( - "Client:", client?._id || "unknown", "|", - "Correlation_ID:", "unknown", "|", - "HTTP:","GET", "|", - "Route:", "/update", "|", - "Status:", "Failure", "|", - "Desc:", "Updating user information", "|", - "Err:", e.message || e, "|", - "Stack:", e.stack || "No Stack Trace"); + "Client:", + client?._id || "unknown", + "|", + "Correlation_ID:", + "unknown", + "|", + "HTTP:", + "GET", + "|", + "Route:", + "/update", + "|", + "Status:", + "Failure", + "|", + "Desc:", + "Updating user information", + "|", + "Err:", + e.message || e, + "|", + "Stack:", + e.stack || "No Stack Trace", + ); g_lib.handleException(e, res); } }) @@ -424,15 +572,27 @@ router for (var i in req.queryParams.uuids) { uuids.push("uuid/" + req.queryParams.uuids[i]); } - + user = g_lib.findUserFromUUIDs(uuids); console.info( - "Client:", user?._id || "unknown", "|", - "Correlation_ID:", "unknown", "|", - "HTTP:","GET", "|", - "Route:", "/find/by_uuids", "|", - "Status:", "Started", "|", - "Desc:", "Find a user from list of UUIDs", "|"); + "Client:", + user?._id || "unknown", + "|", + "Correlation_ID:", + "unknown", + "|", + "HTTP:", + "GET", + "|", + "Route:", + "/find/by_uuids", + "|", + "Status:", + "Started", + "|", + "Desc:", + "Find a user from list of UUIDs" + ); var idents = g_db ._query("for v in 1..1 outbound @user ident return v._key", { @@ -452,23 +612,51 @@ router res.send([user]); console.info( - "Client:", user?._id || "unknown", "|", - "Correlation_ID:", "unknown", "|", - "HTTP:","GET", "|", - "Route:", "/find/by_uuids", "|", - "Status:", "Success", "|", - "Desc:", "Find a user from list of UUIDs", "|"); - + "Client:", + user?._id || "unknown", + "|", + "Correlation_ID:", + "unknown", + "|", + "HTTP:", + "GET", + "|", + "Route:", + "/find/by_uuids", + "|", + "Status:", + "Success", + "|", + "Desc:", + "Find a user from list of UUIDs", + "|", + ); } catch (e) { console.error( - "Client:", user?._id || "unknown", "|", - "Correlation_ID:", "unknown", "|", - "HTTP:","GET", "|", - "Route:", "/find/by_uuids", "|", - "Status:", "Failure", "|", - "Desc:", "Find a user from list of UUIDs", "|", - "Err:", e.message || e, "|", - "Stack:", e.stack || "No Stack Trace"); + "Client:", + user?._id || "unknown", + "|", + "Correlation_ID:", + "unknown", + "|", + "HTTP:", + "GET", + "|", + "Route:", + "/find/by_uuids", + "|", + "Status:", + "Failure", + "|", + "Desc:", + "Find a user from list of UUIDs", + "|", + "Err:", + e.message || e, + "|", + "Stack:", + e.stack || "No Stack Trace", + ); g_lib.handleException(e, res); } }) @@ -480,14 +668,27 @@ router .get("/find/by_name_uid", function (req, res) { let name = undefined; try { - name = req.queryParams.name_uid.trim(); + name = req.queryParams.name_uid.trim(); console.info( - "Client:", name || "unknown", "|", - "Correlation_ID:", "unknown", "|", - "HTTP:","GET", "|", - "Route:", "/find/by_name_uid", "|", - "Status:", "Started", "|", - "Desc:", "Find a user from list of UUIDs", "|"); + "Client:", + name || "unknown", + "|", + "Correlation_ID:", + "unknown", + "|", + "HTTP:", + "GET", + "|", + "Route:", + "/find/by_name_uid", + "|", + "Status:", + "Started", + "|", + "Desc:", + "Find a user from list of UUIDs", + "|", + ); if (name.length < 2) throw [g_lib.ERR_INVALID_PARAM, "Input is too short for name/uid search."]; @@ -521,24 +722,51 @@ router res.send(result); console.info( - "Client:", name || "unknown", "|", - "Correlation_ID:", "unknown", "|", - "HTTP:","GET", "|", - "Route:", "/find/by_name_uid", "|", - "Status:", "Success", "|", - "Desc:", "Find users matching partial name and/or uid", "|"); - - + "Client:", + name || "unknown", + "|", + "Correlation_ID:", + "unknown", + "|", + "HTTP:", + "GET", + "|", + "Route:", + "/find/by_name_uid", + "|", + "Status:", + "Success", + "|", + "Desc:", + "Find users matching partial name and/or uid", + "|", + ); } catch (e) { console.error( - "Client:", name || "unknown", "|", - "Correlation_ID:", "unknown", "|", - "HTTP:","GET", "|", - "Route:", "/find/by_name_uid", "|", - "Status:", "Failure", "|", - "Desc:", "Find users matching partial name and/or uid", "|", - "Err:", e.message || e, "|", - "Stack:", e.stack || "No Stack Trace"); + "Client:", + name || "unknown", + "|", + "Correlation_ID:", + "unknown", + "|", + "HTTP:", + "GET", + "|", + "Route:", + "/find/by_name_uid", + "|", + "Status:", + "Failure", + "|", + "Desc:", + "Find users matching partial name and/or uid", + "|", + "Err:", + e.message || e, + "|", + "Stack:", + e.stack || "No Stack Trace", + ); g_lib.handleException(e, res); } }) @@ -560,12 +788,25 @@ router action: function () { client = g_lib.getUserFromClientID(req.queryParams.client); console.info( - "Client:", client?._id || "unknown", "|", - "Correlation_ID:", "unknown", "|", - "HTTP:","GET", "|", - "Route:", "/keys/set", "|", - "Status:", "Started", "|", - "Desc:", "Set user public and private keys", "|"); + "Client:", + client?._id || "unknown", + "|", + "Correlation_ID:", + "unknown", + "|", + "HTTP:", + "GET", + "|", + "Route:", + "/keys/set", + "|", + "Status:", + "Started", + "|", + "Desc:", + "Set user public and private keys", + "|", + ); var user_id; @@ -588,24 +829,51 @@ router }, }); console.info( - "Client:", client?._id || "unknown", "|", - "Correlation_ID:", "unknown", "|", - "HTTP:","GET", "|", - "Route:", "/keys/set", "|", - "Status:", "Success", "|", - "Desc:", "Set user public and private keys", "|"); - - + "Client:", + client?._id || "unknown", + "|", + "Correlation_ID:", + "unknown", + "|", + "HTTP:", + "GET", + "|", + "Route:", + "/keys/set", + "|", + "Status:", + "Success", + "|", + "Desc:", + "Set user public and private keys", + "|", + ); } catch (e) { console.error( - "Client:", client?._id || "unknown", "|", - "Correlation_ID:", "unknown", "|", - "HTTP:","GET", "|", - "Route:", "/keys/set", "|", - "Status:", "Failure", "|", - "Desc:", "Set user public and private keys", "|", - "Err:", e.message || e, "|", - "Stack:", e.stack || "No Stack Trace"); + "Client:", + client?._id || "unknown", + "|", + "Correlation_ID:", + "unknown", + "|", + "HTTP:", + "GET", + "|", + "Route:", + "/keys/set", + "|", + "Status:", + "Failure", + "|", + "Desc:", + "Set user public and private keys", + "|", + "Err:", + e.message || e, + "|", + "Stack:", + e.stack || "No Stack Trace", + ); g_lib.handleException(e, res); } }) @@ -628,12 +896,25 @@ router action: function () { client = g_lib.getUserFromClientID(req.queryParams.client); console.info( - "Client:", client?._id || "unknown", "|", - "Correlation_ID:", "unknown", "|", - "HTTP:","GET", "|", - "Route:", "/keys/set", "|", - "Status:", "Started", "|", - "Desc:", "Clear user public and private keys", "|"); + "Client:", + client?._id || "unknown", + "|", + "Correlation_ID:", + "unknown", + "|", + "HTTP:", + "GET", + "|", + "Route:", + "/keys/set", + "|", + "Status:", + "Started", + "|", + "Desc:", + "Clear user public and private keys", + "|", + ); var user_id; if (req.queryParams.subject) { @@ -655,22 +936,51 @@ router }, }); console.info( - "Client:", client?._id || "unknown", "|", - "Correlation_ID:", "unknown", "|", - "HTTP:","GET", "|", - "Route:", "/keys/set", "|", - "Status:", "Success", "|", - "Desc:", "Clear user public and private keys", "|"); + "Client:", + client?._id || "unknown", + "|", + "Correlation_ID:", + "unknown", + "|", + "HTTP:", + "GET", + "|", + "Route:", + "/keys/set", + "|", + "Status:", + "Success", + "|", + "Desc:", + "Clear user public and private keys", + "|", + ); } catch (e) { console.error( - "Client:", client?._id || "unknown", "|", - "Correlation_ID:", "unknown", "|", - "HTTP:","GET", "|", - "Route:", "/keys/set", "|", - "Status:", "Failure", "|", - "Desc:", "Clear user public and private keys", "|", - "Err:", e.message || e, "|", - "Stack:", e.stack || "No Stack Trace"); + "Client:", + client?._id || "unknown", + "|", + "Correlation_ID:", + "unknown", + "|", + "HTTP:", + "GET", + "|", + "Route:", + "/keys/set", + "|", + "Status:", + "Failure", + "|", + "Desc:", + "Clear user public and private keys", + "|", + "Err:", + e.message || e, + "|", + "Stack:", + e.stack || "No Stack Trace", + ); g_lib.handleException(e, res); } }) @@ -693,34 +1003,57 @@ router user = g_db.u.document({ _id: req.queryParams.subject, }); - console.info( - "Client:", user?._id || "unknown", "|", - "Correlation_ID:", "unknown", "|", - "HTTP:","GET", "|", - "Route:", "/keys/get", "|", - "Status:", "Started", "|", - "Desc:", "Get user public and private keys", "|"); - + console.info( + "Client:", + user?._id || "unknown", + "|", + "Correlation_ID:", + "unknown", + "|", + "HTTP:", + "GET", + "|", + "Route:", + "/keys/get", + "|", + "Status:", + "Started", + "|", + "Desc:", + "Get user public and private keys", + "|", + ); } else { user = g_lib.getUserFromClientID(req.queryParams.client); } - if (!user.pub_key || !user.priv_key) - { + if (!user.pub_key || !user.priv_key) { res.send([ { uid: user._id, }, ]); - console.info( - "Client:", user?._id || "unknown", "|", - "Correlation_ID:", "unknown", "|", - "HTTP:","GET", "|", - "Route:", "/keys/get", "|", - "Status:", "Success", "|", - "Desc:", "Get user public and private keys", "|"); - } - else + console.info( + "Client:", + user?._id || "unknown", + "|", + "Correlation_ID:", + "unknown", + "|", + "HTTP:", + "GET", + "|", + "Route:", + "/keys/get", + "|", + "Status:", + "Success", + "|", + "Desc:", + "Get user public and private keys", + "|", + ); + } else res.send([ { uid: user._id, @@ -729,23 +1062,51 @@ router }, ]); console.info( - "Client:", user?._id || "unknown", "|", - "Correlation_ID:", "unknown", "|", - "HTTP:","GET", "|", - "Route:", "/keys/get", "|", - "Status:", "Success", "|", - "Desc:", "Get user public and private keys", "|"); - + "Client:", + user?._id || "unknown", + "|", + "Correlation_ID:", + "unknown", + "|", + "HTTP:", + "GET", + "|", + "Route:", + "/keys/get", + "|", + "Status:", + "Success", + "|", + "Desc:", + "Get user public and private keys", + "|", + ); } catch (e) { console.error( - "Client:", user?._id || "unknown", "|", - "Correlation_ID:", "unknown", "|", - "HTTP:","GET", "|", - "Route:", "/keys/get", "|", - "Status:", "Failure", "|", - "Desc:", "Get user public and private keys", "|", - "Err:", e.message || e, "|", - "Stack:", e.stack || "No Stack Trace"); + "Client:", + user?._id || "unknown", + "|", + "Correlation_ID:", + "unknown", + "|", + "HTTP:", + "GET", + "|", + "Route:", + "/keys/get", + "|", + "Status:", + "Failure", + "|", + "Desc:", + "Get user public and private keys", + "|", + "Err:", + e.message || e, + "|", + "Stack:", + e.stack || "No Stack Trace", + ); g_lib.handleException(e, res); } }) @@ -760,31 +1121,73 @@ router try { uid = g_lib.uidFromPubKey(req.queryParams.pub_key); console.info( - "Client:", uid || "unknown", "|", - "Correlation_ID:", "unknown", "|", - "HTTP:","GET", "|", - "Route:", "/find/by_pub_key", "|", - "Status:", "Started", "|", - "Desc:", "Find a user by public key", "|"); + "Client:", + uid || "unknown", + "|", + "Correlation_ID:", + "unknown", + "|", + "HTTP:", + "GET", + "|", + "Route:", + "/find/by_pub_key", + "|", + "Status:", + "Started", + "|", + "Desc:", + "Find a user by public key", + "|", + ); res.send(uid); console.info( - "Client:", uid || "unknown", "|", - "Correlation_ID:", "unknown", "|", - "HTTP:","GET", "|", - "Route:", "/find/by_pub_key", "|", - "Status:", "Success", "|", - "Desc:", "Find a user by public key", "|"); + "Client:", + uid || "unknown", + "|", + "Correlation_ID:", + "unknown", + "|", + "HTTP:", + "GET", + "|", + "Route:", + "/find/by_pub_key", + "|", + "Status:", + "Success", + "|", + "Desc:", + "Find a user by public key", + "|", + ); } catch (e) { console.error( - "Client:", uid || "unknown", "|", - "Correlation_ID:", "unknown", "|", - "HTTP:","GET", "|", - "Route:", "/find/by_pub_key", "|", - "Status:", "Failure", "|", - "Desc:", "Find a user by public key", "|", - "Err:", e.message || e, "|", - "Stack:", e.stack || "No Stack Trace"); + "Client:", + uid || "unknown", + "|", + "Correlation_ID:", + "unknown", + "|", + "HTTP:", + "GET", + "|", + "Route:", + "/find/by_pub_key", + "|", + "Status:", + "Failure", + "|", + "Desc:", + "Find a user by public key", + "|", + "Err:", + e.message || e, + "|", + "Stack:", + e.stack || "No Stack Trace", + ); g_lib.handleException(e, res); } }) @@ -804,12 +1207,25 @@ router action: function () { client = g_lib.getUserFromClientID(req.queryParams.client); console.info( - "Client:", client?._id || "unknown", "|", - "Correlation_ID:", "unknown", "|", - "HTTP:","GET", "|", - "Route:", "/token/set", "|", - "Status:", "Started", "|", - "Desc:", "Setting user token", "|"); + "Client:", + client?._id || "unknown", + "|", + "Correlation_ID:", + "unknown", + "|", + "HTTP:", + "GET", + "|", + "Route:", + "/token/set", + "|", + "Status:", + "Started", + "|", + "Desc:", + "Setting user token", + "|", + ); var user_id; let user_doc; @@ -917,33 +1333,63 @@ router }); break; } - case g_lib.AccessTokenType.GLOBUS_DEFAULT: { - // Existing logic, default actions - g_db._update(user_id, obj, { - keepNull: false, - }); - break; - } - console.info( - "Client:", client?._id || "unknown", "|", - "Correlation_ID:", "unknown", "|", - "HTTP:","GET", "|", - "Route:", "/token/set", "|", - "Status:", "Success", "|", - "Desc:", "Setting user token", "|"); + case g_lib.AccessTokenType.GLOBUS_DEFAULT: + { + // Existing logic, default actions + g_db._update(user_id, obj, { + keepNull: false, + }); + break; + } + console.info( + "Client:", + client?._id || "unknown", + "|", + "Correlation_ID:", + "unknown", + "|", + "HTTP:", + "GET", + "|", + "Route:", + "/token/set", + "|", + "Status:", + "Success", + "|", + "Desc:", + "Setting user token", + "|", + ); } }, }); } catch (e) { console.error( - "Client:", client?._id || "unknown", "|", - "Correlation_ID:", "unknown", "|", - "HTTP:","GET", "|", - "Route:", "/token/set", "|", - "Status:", "Failure", "|", - "Desc:", "Setting user token", "|", - "Err:", e.message || e, "|", - "Stack:", e.stack || "No Stack Trace"); + "Client:", + client?._id || "unknown", + "|", + "Correlation_ID:", + "unknown", + "|", + "HTTP:", + "GET", + "|", + "Route:", + "/token/set", + "|", + "Status:", + "Failure", + "|", + "Desc:", + "Setting user token", + "|", + "Err:", + e.message || e, + "|", + "Stack:", + e.stack || "No Stack Trace", + ); g_lib.handleException(e, res); } }) @@ -981,7 +1427,6 @@ router // TODO: collection type determines logic when mapped vs HA const { collection_id, collection_type } = req.queryParams; - if (req.queryParams.subject) { if (!g_db.u.exists(req.queryParams.subject)) throw [ @@ -995,15 +1440,26 @@ router } else { user = g_lib.getUserFromClientID(req.queryParams.client); } - - console.info( - "Client:",user?._id || "unknown", "|", - "Correlation_ID:", "unknown", "|", - "HTTP:","GET", "|", - "Route:", "usr/token/get/", "|", - "Status:", "Started", "|", - "Desc:", "Getting User Token"); + console.info( + "Client:", + user?._id || "unknown", + "|", + "Correlation_ID:", + "unknown", + "|", + "HTTP:", + "GET", + "|", + "Route:", + "usr/token/get/", + "|", + "Status:", + "Started", + "|", + "Desc:", + "Getting User Token", + ); const user_token = new UserToken({ user_id: user._id, @@ -1022,23 +1478,51 @@ router ); res.send(result); - console.info( - "Client:", user?._id || "unknown", "|", - "Correlation_ID:", "unknown", "|", - "HTTP:","GET", "|", - "Route:", "usr/token/get/", "|", - "Status:", "Success", "|", - "Desc:", "Getting User Token"); + console.info( + "Client:", + user?._id || "unknown", + "|", + "Correlation_ID:", + "unknown", + "|", + "HTTP:", + "GET", + "|", + "Route:", + "usr/token/get/", + "|", + "Status:", + "Success", + "|", + "Desc:", + "Getting User Token", + ); } catch (e) { console.error( - "Client:", user?._id || "unknown", "|", - "Correlation_ID:", "unknown", "|", - "HTTP:","GET", "|", - "Route:", "usr/token/get/", "|", - "Status:", "Failure", "|", - "Desc:", "Getting User Token", "|", - "Err:", e.message || e, "|", - "Stack:", e.stack || "No Stack Trace"); + "Client:", + user?._id || "unknown", + "|", + "Correlation_ID:", + "unknown", + "|", + "HTTP:", + "GET", + "|", + "Route:", + "usr/token/get/", + "|", + "Status:", + "Failure", + "|", + "Desc:", + "Getting User Token", + "|", + "Err:", + e.message || e, + "|", + "Stack:", + e.stack || "No Stack Trace", + ); g_lib.handleException(e, res); } }) @@ -1073,34 +1557,74 @@ router } else { user = g_lib.getUserFromClientID(req.queryParams.client); } - console.info( - "Client:", user?._id || "unknown", "|", - "Correlation_ID:", "unknown", "|", - "HTTP:","GET", "|", - "Route:", "/token/get/access", "|", - "Status:", "Started", "|", - "Desc:", "Getting User Access Token"); + console.info( + "Client:", + user?._id || "unknown", + "|", + "Correlation_ID:", + "unknown", + "|", + "HTTP:", + "GET", + "|", + "Route:", + "/token/get/access", + "|", + "Status:", + "Started", + "|", + "Desc:", + "Getting User Access Token", + ); if (!user.access) throw [g_lib.ERR_NOT_FOUND, "No access token found"]; res.send(user.access); - console.info( - "Client:", user?._id || "unknown", "|", - "Correlation_ID:", "unknown", "|", - "HTTP:","GET", "|", - "Route:", "/token/get/access", "|", - "Status:", "Success", "|", - "Desc:", "Getting User Access Token"); + console.info( + "Client:", + user?._id || "unknown", + "|", + "Correlation_ID:", + "unknown", + "|", + "HTTP:", + "GET", + "|", + "Route:", + "/token/get/access", + "|", + "Status:", + "Success", + "|", + "Desc:", + "Getting User Access Token", + ); } catch (e) { console.error( - "Client:", user?._id || "unknown", "|", - "Correlation_ID:", "unknown", "|", - "HTTP:","GET", "|", - "Route:", "/token/get/access", "|", - "Status:", "Failure", "|", - "Desc:", "Getting User Access Token", "|", - "Err:", e.message || e, "|", - "Stack:", e.stack || "No Stack Trace"); + "Client:", + user?._id || "unknown", + "|", + "Correlation_ID:", + "unknown", + "|", + "HTTP:", + "GET", + "|", + "Route:", + "/token/get/access", + "|", + "Status:", + "Failure", + "|", + "Desc:", + "Getting User Access Token", + "|", + "Err:", + e.message || e, + "|", + "Stack:", + e.stack || "No Stack Trace", + ); g_lib.handleException(e, res); } }) @@ -1115,12 +1639,24 @@ router try { //console.log("exp:",(Date.now()/1000) + req.queryParams.expires_in); console.info( - "Client:", user?._id || "unknown", "|", - "Correlation_ID:", "unknown", "|", - "HTTP:","GET", "|", - "Route:", "/token/get/expiring", "|", - "Status:", "Started", "|", - "Desc:", "Getting expiring user access token"); + "Client:", + user?._id || "unknown", + "|", + "Correlation_ID:", + "unknown", + "|", + "HTTP:", + "GET", + "|", + "Route:", + "/token/get/expiring", + "|", + "Status:", + "Started", + "|", + "Desc:", + "Getting expiring user access token", + ); var results = g_db._query( "for i in u filter i.expiration != Null && i.expiration < @exp return {id:i._id,access:i.access,refresh:i.refresh,expiration:i.expiration}", @@ -1130,22 +1666,50 @@ router ); res.send(results); console.info( - "Client:", user?._id || "unknown", "|", - "Correlation_ID:", "unknown", "|", - "HTTP:","GET", "|", - "Route:", "/token/get/expiring", "|", - "Status:", "Success", "|", - "Desc:", "Getting expiring user access token"); + "Client:", + user?._id || "unknown", + "|", + "Correlation_ID:", + "unknown", + "|", + "HTTP:", + "GET", + "|", + "Route:", + "/token/get/expiring", + "|", + "Status:", + "Success", + "|", + "Desc:", + "Getting expiring user access token", + ); } catch (e) { console.error( - "Client:", user?._id || "unknown", "|", - "Correlation_ID:", "unknown", "|", - "HTTP:","GET", "|", - "Route:", "/token/get/expiring", "|", - "Status:", "Failure", "|", - "Desc:", "Getting expiring user access token", "|", - "Err:", e.message || e, "|", - "Stack:", e.stack || "No Stack Trace"); + "Client:", + user?._id || "unknown", + "|", + "Correlation_ID:", + "unknown", + "|", + "HTTP:", + "GET", + "|", + "Route:", + "/token/get/expiring", + "|", + "Status:", + "Failure", + "|", + "Desc:", + "Getting expiring user access token", + "|", + "Err:", + e.message || e, + "|", + "Stack:", + e.stack || "No Stack Trace", + ); g_lib.handleException(e, res); } }) @@ -1160,12 +1724,24 @@ router try { client = g_lib.getUserFromClientID_noexcept(req.queryParams.client); console.info( - "Client:", client?._id || "unknown", "|", - "Correlation_ID:", "unknown", "|", - "HTTP:","GET", "|", - "Route:", "/view", "|", - "Status:", "Started", "|", - "Desc:", "View User Information"); + "Client:", + client?._id || "unknown", + "|", + "Correlation_ID:", + "unknown", + "|", + "HTTP:", + "GET", + "|", + "Route:", + "/view", + "|", + "Status:", + "Started", + "|", + "Desc:", + "View User Information", + ); var user, det_ok = false; @@ -1247,24 +1823,51 @@ router res.send([user]); console.info( - "Client:", client?._id || "unknown", "|", - "Correlation_ID:", "unknown", "|", - "HTTP:","GET", "|", - "Route:", "/view", "|", - "Status:", "Success", "|", - "Desc:", "View User Information"); - + "Client:", + client?._id || "unknown", + "|", + "Correlation_ID:", + "unknown", + "|", + "HTTP:", + "GET", + "|", + "Route:", + "/view", + "|", + "Status:", + "Success", + "|", + "Desc:", + "View User Information", + ); } catch (e) { g_lib.handleException(e, res); console.error( - "Client:", client?._id || "unknown", "|", - "Correlation_ID:", "unknown", "|", - "HTTP:","GET", "|", - "Route:", "/view", "|", - "Status:", "Failure", "|", - "Desc:", "View User Information", "|", - "Err:", e.message || e, "|", - "Stack:", e.stack || "No Stack Trace"); + "Client:", + client?._id || "unknown", + "|", + "Correlation_ID:", + "unknown", + "|", + "HTTP:", + "GET", + "|", + "Route:", + "/view", + "|", + "Status:", + "Failure", + "|", + "Desc:", + "View User Information", + "|", + "Err:", + e.message || e, + "|", + "Stack:", + e.stack || "No Stack Trace", + ); } }) .queryParam("client", joi.string().required(), "Client ID") @@ -1275,17 +1878,28 @@ router router .get("/list/all", function (req, res) { - var client = undefined; + let client = undefined; var qry = "for i in u sort i.name_last, i.name_first"; var result; console.info( - "Client:", client?._id || "unknown", "|", - "Correlation_ID:", "unknown", "|", - "HTTP:","GET", "|", - "Route:", "/list/all", "|", - "Status:", "Started", "|", - "Desc:", "List all users"); - + "Client:", + client?._id || "unknown", + "|", + "Correlation_ID:", + "unknown", + "|", + "HTTP:", + "GET", + "|", + "Route:", + "/list/all", + "|", + "Status:", + "Started", + "|", + "Desc:", + "List all users", + ); if (req.queryParams.offset != undefined && req.queryParams.count != undefined) { qry += @@ -1318,12 +1932,24 @@ router res.send(result); console.info( - "Client:", client?._id || "unknown", "|", - "Correlation_ID:", "unknown", "|", - "HTTP:","GET", "|", - "Route:", "/list/all", "|", - "Status:", "Success", "|", - "Desc:", "List all users"); + "Client:", + client?._id || "unknown", + "|", + "Correlation_ID:", + "unknown", + "|", + "HTTP:", + "GET", + "|", + "Route:", + "/list/all", + "|", + "Status:", + "Success", + "|", + "Desc:", + "List all users", + ); }) .queryParam("offset", joi.number().optional(), "Offset") .queryParam("count", joi.number().optional(), "Count") @@ -1335,12 +1961,24 @@ router var result, client = g_lib.getUserFromClientID(req.queryParams.client); console.info( - "Client:", client?._id || "unknown", "|", - "Correlation_ID:", "unknown", "|", - "HTTP:","GET", "|", - "Route:", "/list/collab", "|", - "Status:", "Started", "|", - "Desc:", "List collaborators of client"); + "Client:", + client?._id || "unknown", + "|", + "Correlation_ID:", + "unknown", + "|", + "HTTP:", + "GET", + "|", + "Route:", + "/list/collab", + "|", + "Status:", + "Started", + "|", + "Desc:", + "List collaborators of client", + ); var qry = "for x in union_distinct((for v in 2..2 any @user owner, member, acl filter is_same_collection('u',v) return" + @@ -1383,12 +2021,24 @@ router res.send(result); console.info( - "Client:", client?._id || "unknown", "|", - "Correlation_ID:", "unknown", "|", - "HTTP:","GET", "|", - "Route:", "/list/collab", "|", - "Status:", "Success", "|", - "Desc:", "List collaborators of client"); + "Client:", + client?._id || "unknown", + "|", + "Correlation_ID:", + "unknown", + "|", + "HTTP:", + "GET", + "|", + "Route:", + "/list/collab", + "|", + "Status:", + "Success", + "|", + "Desc:", + "List collaborators of client", + ); //res.send( g_db._query( "for x in union_distinct((for v in 2..2 any @user owner, member, acl filter is_same_collection('u',v) return distinct { uid: v._id, name: v.name }),(for v in 3..3 inbound @user member, outbound owner, outbound admin filter is_same_collection('u',v) return distinct { uid: v._id, name: v.name }),(for v in 2..2 inbound @user owner, outbound admin filter is_same_collection('u',v) return distinct { uid: v._id, name: v.name })) return x", { user: client._id })); }) @@ -1404,6 +2054,7 @@ Note: must delete ALL data records and projects owned by the user being deleted */ router .get("/delete", function (req, res) { + let client = undefined; try { g_db._executeTransaction({ collections: { @@ -1429,15 +2080,27 @@ router ], }, action: function () { - const client = g_lib.getUserFromClientID(req.queryParams.client); + client = g_lib.getUserFromClientID(req.queryParams.client); var user_id; console.info( - "Client:", client?._id || "unknown", "|", - "Correlation_ID:", "unknown", "|", - "HTTP:","GET", "|", - "Route:", "/delete", "|", - "Status:", "Started", "|", - "Desc:", "Remove existing user entry"); + "Client:", + client?._id || "unknown", + "|", + "Correlation_ID:", + "unknown", + "|", + "HTTP:", + "GET", + "|", + "Route:", + "/delete", + "|", + "Status:", + "Started", + "|", + "Desc:", + "Remove existing user entry", + ); if (req.queryParams.subject) { user_id = req.queryParams.subject; @@ -1505,22 +2168,50 @@ router }, }); console.info( - "Client:", client?._id || "unknown", "|", - "Correlation_ID:", "unknown", "|", - "HTTP:","GET", "|", - "Route:", "/delete", "|", - "Status:", "Success", "|", - "Desc:", "Remove existing user entry"); + "Client:", + client?._id || "unknown", + "|", + "Correlation_ID:", + "unknown", + "|", + "HTTP:", + "GET", + "|", + "Route:", + "/delete", + "|", + "Status:", + "Success", + "|", + "Desc:", + "Remove existing user entry", + ); } catch (e) { console.error( - "Client:", client?._id || "unknown", "|", - "Correlation_ID:", "unknown", "|", - "HTTP:","GET", "|", - "Route:", "/delete", "|", - "Status:", "Failure", "|", - "Desc:", "Remove existing user entry", "|", - "Err:", e.message || e, "|", - "Stack:", e.stack || "No Stack Trace"); + "Client:", + client?._id || "unknown", + "|", + "Correlation_ID:", + "unknown", + "|", + "HTTP:", + "GET", + "|", + "Route:", + "/delete", + "|", + "Status:", + "Failure", + "|", + "Desc:", + "Remove existing user entry", + "|", + "Err:", + e.message || e, + "|", + "Stack:", + e.stack || "No Stack Trace", + ); g_lib.handleException(e, res); } }) @@ -1534,14 +2225,25 @@ router let client = undefined; try { client = g_lib.getUserFromClientID(req.queryParams.client); - console.info( - "Client:", client?._id || "unknown", "|", - "Correlation_ID:", "unknown", "|", - "HTTP:","GET", "|", - "Route:", "/ident/list", "|", - "Status:", "Started", "|", - "Desc:", "List user linked IDs"); - + console.info( + "Client:", + client?._id || "unknown", + "|", + "Correlation_ID:", + "unknown", + "|", + "HTTP:", + "GET", + "|", + "Route:", + "/ident/list", + "|", + "Status:", + "Started", + "|", + "Desc:", + "List user linked IDs", + ); if (req.queryParams.subject) { if (!g_db.u.exists(req.queryParams.subject)) @@ -1558,38 +2260,76 @@ router }), ); console.info( - "Client:", client?._id || "unknown", "|", - "Correlation_ID:", "unknown", "|", - "HTTP:","GET", "|", - "Route:", "/ident/list", "|", - "Status:", "Success", "|", - "Desc:", "List user linked IDs"); - - + "Client:", + client?._id || "unknown", + "|", + "Correlation_ID:", + "unknown", + "|", + "HTTP:", + "GET", + "|", + "Route:", + "/ident/list", + "|", + "Status:", + "Success", + "|", + "Desc:", + "List user linked IDs", + ); } else { - res.send(g_db._query("for v in 1..1 outbound @client ident return v._key", { + res.send( + g_db._query("for v in 1..1 outbound @client ident return v._key", { client: client._id, }), ); console.info( - "Client:", client?._id || "unknown", "|", - "Correlation_ID:", "unknown", "|", - "HTTP:","GET", "|", - "Route:", "/ident/list", "|", - "Status:", "Success", "|", - "Desc:", "List user linked IDs"); - + "Client:", + client?._id || "unknown", + "|", + "Correlation_ID:", + "unknown", + "|", + "HTTP:", + "GET", + "|", + "Route:", + "/ident/list", + "|", + "Status:", + "Success", + "|", + "Desc:", + "List user linked IDs", + ); } } catch (e) { console.error( - "Client:", client?._id || "unknown", "|", - "Correlation_ID:", "unknown", "|", - "HTTP:","GET", "|", - "Route:", "/ident/list", "|", - "Status:", "Failure", "|", - "Desc:", "List user linked IDs", "|", - "Err:", e.message || e, "|", - "Stack:", e.stack || "No Stack Trace"); + "Client:", + client?._id || "unknown", + "|", + "Correlation_ID:", + "unknown", + "|", + "HTTP:", + "GET", + "|", + "Route:", + "/ident/list", + "|", + "Status:", + "Failure", + "|", + "Desc:", + "List user linked IDs", + "|", + "Err:", + e.message || e, + "|", + "Stack:", + e.stack || "No Stack Trace", + ); g_lib.handleException(e, res); } }) @@ -1609,12 +2349,24 @@ router action: function () { client = g_lib.getUserFromClientID(req.queryParams.client); console.info( - "Client:", client?._id || "unknown", "|", - "Correlation_ID:", "unknown", "|", - "HTTP:","GET", "|", - "Route:", "/ident/add", "|", - "Status:", "Started", "|", - "Desc:", "Add new linked identity"); + "Client:", + client?._id || "unknown", + "|", + "Correlation_ID:", + "unknown", + "|", + "HTTP:", + "GET", + "|", + "Route:", + "/ident/add", + "|", + "Status:", + "Started", + "|", + "Desc:", + "Add new linked identity", + ); var id; if (g_lib.isUUID(req.queryParams.ident)) { @@ -1624,13 +2376,25 @@ router }) ) console.info( - "Client:", client?._id || "unknown", "|", - "Correlation_ID:", "unknown", "|", - "HTTP:","GET", "|", - "Route:", "/ident/add", "|", - "Status:", "Success", "|", - "Desc:", "Add new linked identity"); - return; + "Client:", + client?._id || "unknown", + "|", + "Correlation_ID:", + "unknown", + "|", + "HTTP:", + "GET", + "|", + "Route:", + "/ident/add", + "|", + "Status:", + "Success", + "|", + "Desc:", + "Add new linked identity", + ); + return; id = g_db.uuid.save( { _key: req.queryParams.ident, @@ -1658,12 +2422,24 @@ router ); } console.info( - "Client:", client?._id || "unknown", "|", - "Correlation_ID:", "unknown", "|", - "HTTP:","GET", "|", - "Route:", "/ident/add", "|", - "Status:", "Success", "|", - "Desc:", "Add new linked identity"); + "Client:", + client?._id || "unknown", + "|", + "Correlation_ID:", + "unknown", + "|", + "HTTP:", + "GET", + "|", + "Route:", + "/ident/add", + "|", + "Status:", + "Success", + "|", + "Desc:", + "Add new linked identity", + ); return; } else { var accn = { @@ -1705,23 +2481,51 @@ router } }, }); - console.info( - "Client:", client?._id || "unknown", "|", - "Correlation_ID:", "unknown", "|", - "HTTP:","GET", "|", - "Route:", "/ident/add", "|", - "Status:", "Success", "|", - "Desc:", "Add new linked identity"); + console.info( + "Client:", + client?._id || "unknown", + "|", + "Correlation_ID:", + "unknown", + "|", + "HTTP:", + "GET", + "|", + "Route:", + "/ident/add", + "|", + "Status:", + "Success", + "|", + "Desc:", + "Add new linked identity", + ); } catch (e) { console.error( - "Client:", client?._id || "unknown", "|", - "Correlation_ID:", "unknown", "|", - "HTTP:","GET", "|", - "Route:", "/ident/add", "|", - "Status:", "Failure", "|", - "Desc:", "Add new linked identity", "|", - "Err:", e.message || e, "|", - "Stack:", e.stack || "No Stack Trace"); + "Client:", + client?._id || "unknown", + "|", + "Correlation_ID:", + "unknown", + "|", + "HTTP:", + "GET", + "|", + "Route:", + "/ident/add", + "|", + "Status:", + "Failure", + "|", + "Desc:", + "Add new linked identity", + "|", + "Err:", + e.message || e, + "|", + "Stack:", + e.stack || "No Stack Trace", + ); g_lib.handleException(e, res); } }) @@ -1748,12 +2552,24 @@ router client = g_lib.getUserFromClientID(req.queryParams.client); const owner = g_lib.getUserFromClientID(req.queryParams.ident); console.info( - "Client:", client?._id || "unknown", "|", - "Correlation_ID:", "unknown", "|", - "HTTP:","GET", "|", - "Route:", "/ident/remove", "|", - "Status:", "Started", "|", - "Desc:", "Remove linked identity from user account"); + "Client:", + client?._id || "unknown", + "|", + "Correlation_ID:", + "unknown", + "|", + "HTTP:", + "GET", + "|", + "Route:", + "/ident/remove", + "|", + "Status:", + "Started", + "|", + "Desc:", + "Remove linked identity from user account", + ); g_lib.ensureAdminPermUser(client, owner._id); if (g_lib.isUUID(req.queryParams.ident)) { @@ -1768,23 +2584,50 @@ router }, }); console.info( - "Client:", client?._id || "unknown", "|", - "Correlation_ID:", "unknown", "|", - "HTTP:","GET", "|", - "Route:", "/ident/remove", "|", - "Status:", "Success", "|", - "Desc:", "Remove linked identity from user account"); - + "Client:", + client?._id || "unknown", + "|", + "Correlation_ID:", + "unknown", + "|", + "HTTP:", + "GET", + "|", + "Route:", + "/ident/remove", + "|", + "Status:", + "Success", + "|", + "Desc:", + "Remove linked identity from user account", + ); } catch (e) { console.error( - "Client:", client?._id || "unknown", "|", - "Correlation_ID:", "unknown", "|", - "HTTP:","GET", "|", - "Route:", "/ident/remove", "|", - "Status:", "Failure", "|", - "Desc:", "Remove linked identity from user account", "|", - "Err:", e.message || e, "|", - "Stack:", e.stack || "No Stack Trace"); + "Client:", + client?._id || "unknown", + "|", + "Correlation_ID:", + "unknown", + "|", + "HTTP:", + "GET", + "|", + "Route:", + "/ident/remove", + "|", + "Status:", + "Failure", + "|", + "Desc:", + "Remove linked identity from user account", + "|", + "Err:", + e.message || e, + "|", + "Stack:", + e.stack || "No Stack Trace", + ); g_lib.handleException(e, res); } }) @@ -1799,31 +2642,71 @@ router try { client = g_lib.getUserFromClientID(req.queryParams.client); console.info( - "Client:", client?._id || "unknown", "|", - "Correlation_ID:", "unknown", "|", - "HTTP:","GET", "|", - "Route:", "/ep/get", "|", - "Status:", "Started", "|", - "Desc:", "Get recent end-points"); + "Client:", + client?._id || "unknown", + "|", + "Correlation_ID:", + "unknown", + "|", + "HTTP:", + "GET", + "|", + "Route:", + "/ep/get", + "|", + "Status:", + "Started", + "|", + "Desc:", + "Get recent end-points", + ); res.send(client.eps ? client.eps : []); console.info( - "Client:", client?._id || "unknown", "|", - "Correlation_ID:", "unknown", "|", - "HTTP:","GET", "|", - "Route:", "/ep/get", "|", - "Status:", "Success", "|", - "Desc:", "Get recent end-points"); + "Client:", + client?._id || "unknown", + "|", + "Correlation_ID:", + "unknown", + "|", + "HTTP:", + "GET", + "|", + "Route:", + "/ep/get", + "|", + "Status:", + "Success", + "|", + "Desc:", + "Get recent end-points", + ); } catch (e) { console.error( - "Client:", client?._id || "unknown", "|", - "Correlation_ID:", "unknown", "|", - "HTTP:","GET", "|", - "Route:", "/ep/get", "|", - "Status:", "Failure", "|", - "Desc:", "Get recent end-points", "|", - "Err:", e.message || e, "|", - "Stack:", e.stack || "No Stack Trace"); + "Client:", + client?._id || "unknown", + "|", + "Correlation_ID:", + "unknown", + "|", + "HTTP:", + "GET", + "|", + "Route:", + "/ep/get", + "|", + "Status:", + "Failure", + "|", + "Desc:", + "Get recent end-points", + "|", + "Err:", + e.message || e, + "|", + "Stack:", + e.stack || "No Stack Trace", + ); g_lib.handleException(e, res); } }) @@ -1837,12 +2720,24 @@ router try { client = g_lib.getUserFromClientID(req.queryParams.client); console.info( - "Client:", client?._id || "unknown", "|", - "Correlation_ID:", "unknown", "|", - "HTTP:","GET", "|", - "Route:", "/ep/set", "|", - "Status:", "Started", "|", - "Desc:", "Set recent end-points"); + "Client:", + client?._id || "unknown", + "|", + "Correlation_ID:", + "unknown", + "|", + "HTTP:", + "GET", + "|", + "Route:", + "/ep/set", + "|", + "Status:", + "Started", + "|", + "Desc:", + "Set recent end-points", + ); g_db._update( client._id, @@ -1853,24 +2748,51 @@ router keepNull: false, }, ); - console.info( - "Client:", client?._id || "unknown", "|", - "Correlation_ID:", "unknown", "|", - "HTTP:","GET", "|", - "Route:", "/ep/set", "|", - "Status:", "Success", "|", - "Desc:", "Set recent end-points"); - + console.info( + "Client:", + client?._id || "unknown", + "|", + "Correlation_ID:", + "unknown", + "|", + "HTTP:", + "GET", + "|", + "Route:", + "/ep/set", + "|", + "Status:", + "Success", + "|", + "Desc:", + "Set recent end-points", + ); } catch (e) { console.error( - "Client:", client?._id || "unknown", "|", - "Correlation_ID:", "unknown", "|", - "HTTP:","GET", "|", - "Route:", "/ep/set", "|", - "Status:", "Failure", "|", - "Desc:", "Set recent end-points", "|", - "Err:", e.message || e, "|", - "Stack:", e.stack || "No Stack Trace"); + "Client:", + client?._id || "unknown", + "|", + "Correlation_ID:", + "unknown", + "|", + "HTTP:", + "GET", + "|", + "Route:", + "/ep/set", + "|", + "Status:", + "Failure", + "|", + "Desc:", + "Set recent end-points", + "|", + "Err:", + e.message || e, + "|", + "Stack:", + e.stack || "No Stack Trace", + ); g_lib.handleException(e, res); } }) From 35c5bc24011b0f3b30a657ce35d19f0d82e39267 Mon Sep 17 00:00:00 2001 From: Austin Hampton Date: Wed, 27 Aug 2025 15:06:35 -0400 Subject: [PATCH 05/36] refactor: changed correlation id within logs to use req.headers['x-correlation-id'] instead of just having placeholder text --- core/database/foxx/api/user_router.js | 142 +++++++++++++------------- 1 file changed, 71 insertions(+), 71 deletions(-) diff --git a/core/database/foxx/api/user_router.js b/core/database/foxx/api/user_router.js index 94788df21..196617204 100644 --- a/core/database/foxx/api/user_router.js +++ b/core/database/foxx/api/user_router.js @@ -29,7 +29,7 @@ router "Client:", client?._id || "unknown", "Correlation_ID:", - "unknown", + req.headers['x-correlation-id'], "HTTP:", "GET", "Route:", @@ -51,7 +51,7 @@ router "Client:", client?._id || "unknown", "Correlation_ID:", - "unknown", + req.headers['x-correlation-id'], "HTTP:", "GET", "Route:", @@ -67,7 +67,7 @@ router client?._id || "unknown", "|", "Correlation_ID:", - "unknown", + req.headers['x-correlation-id'], "|", "HTTP:", "GET", @@ -107,7 +107,7 @@ router user?._id || "unknown", "|", "Correlation_ID:", - "unknown", + req.headers['x-correlation-id'], "|", "HTTP:", "GET", @@ -133,7 +133,7 @@ router user?._id || "unknown", "|", "Correlation_ID:", - "unknown", + req.headers['x-correlation-id'], "|", "HTTP:", "GET", @@ -153,7 +153,7 @@ router user?._id || "unknown", "|", "Correlation_ID:", - "unknown", + req.headers['x-correlation-id'], "|", "HTTP:", "GET", @@ -248,7 +248,7 @@ router user?._id || "unknown", "|", "Correlation_ID:", - "unknown", + req.headers['x-correlation-id'], "|", "HTTP:", "GET", @@ -350,7 +350,7 @@ router user?._id || "unknown", "|", "Correlation_ID:", - "unknown", + req.headers['x-correlation-id'], "|", "HTTP:", "GET", @@ -371,7 +371,7 @@ router user?._id || "unknown", "|", "Correlation_ID:", - "unknown", + req.headers['x-correlation-id'], "|", "HTTP:", "GET", @@ -428,7 +428,7 @@ router client?._id || "unknown", "|", "Correlation_ID:", - "unknown", + req.headers['x-correlation-id'], "|", "HTTP:", "GET", @@ -509,7 +509,7 @@ router client?._id || "unknown", "|", "Correlation_ID:", - "unknown", + req.headers['x-correlation-id'], "|", "HTTP:", "GET", @@ -530,7 +530,7 @@ router client?._id || "unknown", "|", "Correlation_ID:", - "unknown", + req.headers['x-correlation-id'], "|", "HTTP:", "GET", @@ -579,7 +579,7 @@ router user?._id || "unknown", "|", "Correlation_ID:", - "unknown", + req.headers['x-correlation-id'], "|", "HTTP:", "GET", @@ -616,7 +616,7 @@ router user?._id || "unknown", "|", "Correlation_ID:", - "unknown", + req.headers['x-correlation-id'], "|", "HTTP:", "GET", @@ -637,7 +637,7 @@ router user?._id || "unknown", "|", "Correlation_ID:", - "unknown", + req.headers['x-correlation-id'], "|", "HTTP:", "GET", @@ -674,7 +674,7 @@ router name || "unknown", "|", "Correlation_ID:", - "unknown", + req.headers['x-correlation-id'], "|", "HTTP:", "GET", @@ -726,7 +726,7 @@ router name || "unknown", "|", "Correlation_ID:", - "unknown", + req.headers['x-correlation-id'], "|", "HTTP:", "GET", @@ -747,7 +747,7 @@ router name || "unknown", "|", "Correlation_ID:", - "unknown", + req.headers['x-correlation-id'], "|", "HTTP:", "GET", @@ -792,7 +792,7 @@ router client?._id || "unknown", "|", "Correlation_ID:", - "unknown", + req.headers['x-correlation-id'], "|", "HTTP:", "GET", @@ -833,7 +833,7 @@ router client?._id || "unknown", "|", "Correlation_ID:", - "unknown", + req.headers['x-correlation-id'], "|", "HTTP:", "GET", @@ -854,7 +854,7 @@ router client?._id || "unknown", "|", "Correlation_ID:", - "unknown", + req.headers['x-correlation-id'], "|", "HTTP:", "GET", @@ -900,7 +900,7 @@ router client?._id || "unknown", "|", "Correlation_ID:", - "unknown", + req.headers['x-correlation-id'], "|", "HTTP:", "GET", @@ -940,7 +940,7 @@ router client?._id || "unknown", "|", "Correlation_ID:", - "unknown", + req.headers['x-correlation-id'], "|", "HTTP:", "GET", @@ -961,7 +961,7 @@ router client?._id || "unknown", "|", "Correlation_ID:", - "unknown", + req.headers['x-correlation-id'], "|", "HTTP:", "GET", @@ -1008,7 +1008,7 @@ router user?._id || "unknown", "|", "Correlation_ID:", - "unknown", + req.headers['x-correlation-id'], "|", "HTTP:", "GET", @@ -1038,7 +1038,7 @@ router user?._id || "unknown", "|", "Correlation_ID:", - "unknown", + req.headers['x-correlation-id'], "|", "HTTP:", "GET", @@ -1066,7 +1066,7 @@ router user?._id || "unknown", "|", "Correlation_ID:", - "unknown", + req.headers['x-correlation-id'], "|", "HTTP:", "GET", @@ -1087,7 +1087,7 @@ router user?._id || "unknown", "|", "Correlation_ID:", - "unknown", + req.headers['x-correlation-id'], "|", "HTTP:", "GET", @@ -1125,7 +1125,7 @@ router uid || "unknown", "|", "Correlation_ID:", - "unknown", + req.headers['x-correlation-id'], "|", "HTTP:", "GET", @@ -1147,7 +1147,7 @@ router uid || "unknown", "|", "Correlation_ID:", - "unknown", + req.headers['x-correlation-id'], "|", "HTTP:", "GET", @@ -1168,7 +1168,7 @@ router uid || "unknown", "|", "Correlation_ID:", - "unknown", + req.headers['x-correlation-id'], "|", "HTTP:", "GET", @@ -1211,7 +1211,7 @@ router client?._id || "unknown", "|", "Correlation_ID:", - "unknown", + req.headers['x-correlation-id'], "|", "HTTP:", "GET", @@ -1346,7 +1346,7 @@ router client?._id || "unknown", "|", "Correlation_ID:", - "unknown", + req.headers['x-correlation-id'], "|", "HTTP:", "GET", @@ -1370,7 +1370,7 @@ router client?._id || "unknown", "|", "Correlation_ID:", - "unknown", + req.headers['x-correlation-id'], "|", "HTTP:", "GET", @@ -1446,7 +1446,7 @@ router user?._id || "unknown", "|", "Correlation_ID:", - "unknown", + req.headers['x-correlation-id'], "|", "HTTP:", "GET", @@ -1483,7 +1483,7 @@ router user?._id || "unknown", "|", "Correlation_ID:", - "unknown", + req.headers['x-correlation-id'], "|", "HTTP:", "GET", @@ -1503,7 +1503,7 @@ router user?._id || "unknown", "|", "Correlation_ID:", - "unknown", + req.headers['x-correlation-id'], "|", "HTTP:", "GET", @@ -1562,7 +1562,7 @@ router user?._id || "unknown", "|", "Correlation_ID:", - "unknown", + req.headers['x-correlation-id'], "|", "HTTP:", "GET", @@ -1585,7 +1585,7 @@ router user?._id || "unknown", "|", "Correlation_ID:", - "unknown", + req.headers['x-correlation-id'], "|", "HTTP:", "GET", @@ -1605,7 +1605,7 @@ router user?._id || "unknown", "|", "Correlation_ID:", - "unknown", + req.headers['x-correlation-id'], "|", "HTTP:", "GET", @@ -1643,7 +1643,7 @@ router user?._id || "unknown", "|", "Correlation_ID:", - "unknown", + req.headers['x-correlation-id'], "|", "HTTP:", "GET", @@ -1670,7 +1670,7 @@ router user?._id || "unknown", "|", "Correlation_ID:", - "unknown", + req.headers['x-correlation-id'], "|", "HTTP:", "GET", @@ -1690,7 +1690,7 @@ router user?._id || "unknown", "|", "Correlation_ID:", - "unknown", + req.headers['x-correlation-id'], "|", "HTTP:", "GET", @@ -1728,7 +1728,7 @@ router client?._id || "unknown", "|", "Correlation_ID:", - "unknown", + req.headers['x-correlation-id'], "|", "HTTP:", "GET", @@ -1827,7 +1827,7 @@ router client?._id || "unknown", "|", "Correlation_ID:", - "unknown", + req.headers['x-correlation-id'], "|", "HTTP:", "GET", @@ -1848,7 +1848,7 @@ router client?._id || "unknown", "|", "Correlation_ID:", - "unknown", + req.headers['x-correlation-id'], "|", "HTTP:", "GET", @@ -1886,7 +1886,7 @@ router client?._id || "unknown", "|", "Correlation_ID:", - "unknown", + req.headers['x-correlation-id'], "|", "HTTP:", "GET", @@ -1936,7 +1936,7 @@ router client?._id || "unknown", "|", "Correlation_ID:", - "unknown", + req.headers['x-correlation-id'], "|", "HTTP:", "GET", @@ -1965,7 +1965,7 @@ router client?._id || "unknown", "|", "Correlation_ID:", - "unknown", + req.headers['x-correlation-id'], "|", "HTTP:", "GET", @@ -2025,7 +2025,7 @@ router client?._id || "unknown", "|", "Correlation_ID:", - "unknown", + req.headers['x-correlation-id'], "|", "HTTP:", "GET", @@ -2087,7 +2087,7 @@ router client?._id || "unknown", "|", "Correlation_ID:", - "unknown", + req.headers['x-correlation-id'], "|", "HTTP:", "GET", @@ -2172,7 +2172,7 @@ router client?._id || "unknown", "|", "Correlation_ID:", - "unknown", + req.headers['x-correlation-id'], "|", "HTTP:", "GET", @@ -2192,7 +2192,7 @@ router client?._id || "unknown", "|", "Correlation_ID:", - "unknown", + req.headers['x-correlation-id'], "|", "HTTP:", "GET", @@ -2230,7 +2230,7 @@ router client?._id || "unknown", "|", "Correlation_ID:", - "unknown", + req.headers['x-correlation-id'], "|", "HTTP:", "GET", @@ -2264,7 +2264,7 @@ router client?._id || "unknown", "|", "Correlation_ID:", - "unknown", + req.headers['x-correlation-id'], "|", "HTTP:", "GET", @@ -2289,7 +2289,7 @@ router client?._id || "unknown", "|", "Correlation_ID:", - "unknown", + req.headers['x-correlation-id'], "|", "HTTP:", "GET", @@ -2310,7 +2310,7 @@ router client?._id || "unknown", "|", "Correlation_ID:", - "unknown", + req.headers['x-correlation-id'], "|", "HTTP:", "GET", @@ -2353,7 +2353,7 @@ router client?._id || "unknown", "|", "Correlation_ID:", - "unknown", + req.headers['x-correlation-id'], "|", "HTTP:", "GET", @@ -2380,7 +2380,7 @@ router client?._id || "unknown", "|", "Correlation_ID:", - "unknown", + req.headers['x-correlation-id'], "|", "HTTP:", "GET", @@ -2426,7 +2426,7 @@ router client?._id || "unknown", "|", "Correlation_ID:", - "unknown", + req.headers['x-correlation-id'], "|", "HTTP:", "GET", @@ -2486,7 +2486,7 @@ router client?._id || "unknown", "|", "Correlation_ID:", - "unknown", + req.headers['x-correlation-id'], "|", "HTTP:", "GET", @@ -2506,7 +2506,7 @@ router client?._id || "unknown", "|", "Correlation_ID:", - "unknown", + req.headers['x-correlation-id'], "|", "HTTP:", "GET", @@ -2556,7 +2556,7 @@ router client?._id || "unknown", "|", "Correlation_ID:", - "unknown", + req.headers['x-correlation-id'], "|", "HTTP:", "GET", @@ -2588,7 +2588,7 @@ router client?._id || "unknown", "|", "Correlation_ID:", - "unknown", + req.headers['x-correlation-id'], "|", "HTTP:", "GET", @@ -2608,7 +2608,7 @@ router client?._id || "unknown", "|", "Correlation_ID:", - "unknown", + req.headers['x-correlation-id'], "|", "HTTP:", "GET", @@ -2646,7 +2646,7 @@ router client?._id || "unknown", "|", "Correlation_ID:", - "unknown", + req.headers['x-correlation-id'], "|", "HTTP:", "GET", @@ -2667,7 +2667,7 @@ router client?._id || "unknown", "|", "Correlation_ID:", - "unknown", + req.headers['x-correlation-id'], "|", "HTTP:", "GET", @@ -2687,7 +2687,7 @@ router client?._id || "unknown", "|", "Correlation_ID:", - "unknown", + req.headers['x-correlation-id'], "|", "HTTP:", "GET", @@ -2724,7 +2724,7 @@ router client?._id || "unknown", "|", "Correlation_ID:", - "unknown", + req.headers['x-correlation-id'], "|", "HTTP:", "GET", @@ -2753,7 +2753,7 @@ router client?._id || "unknown", "|", "Correlation_ID:", - "unknown", + req.headers['x-correlation-id'], "|", "HTTP:", "GET", @@ -2773,7 +2773,7 @@ router client?._id || "unknown", "|", "Correlation_ID:", - "unknown", + req.headers['x-correlation-id'], "|", "HTTP:", "GET", From 17a3629600765f8bf434a0bc7c7ef916157f148f Mon Sep 17 00:00:00 2001 From: Austin Hampton Date: Thu, 28 Aug 2025 14:56:26 +0000 Subject: [PATCH 06/36] chore: Auto-format JavaScript files with Prettier --- core/database/foxx/api/user_router.js | 144 +++++++++++++------------- 1 file changed, 72 insertions(+), 72 deletions(-) diff --git a/core/database/foxx/api/user_router.js b/core/database/foxx/api/user_router.js index 196617204..f1169862b 100644 --- a/core/database/foxx/api/user_router.js +++ b/core/database/foxx/api/user_router.js @@ -29,7 +29,7 @@ router "Client:", client?._id || "unknown", "Correlation_ID:", - req.headers['x-correlation-id'], + req.headers["x-correlation-id"], "HTTP:", "GET", "Route:", @@ -51,7 +51,7 @@ router "Client:", client?._id || "unknown", "Correlation_ID:", - req.headers['x-correlation-id'], + req.headers["x-correlation-id"], "HTTP:", "GET", "Route:", @@ -67,7 +67,7 @@ router client?._id || "unknown", "|", "Correlation_ID:", - req.headers['x-correlation-id'], + req.headers["x-correlation-id"], "|", "HTTP:", "GET", @@ -107,7 +107,7 @@ router user?._id || "unknown", "|", "Correlation_ID:", - req.headers['x-correlation-id'], + req.headers["x-correlation-id"], "|", "HTTP:", "GET", @@ -133,7 +133,7 @@ router user?._id || "unknown", "|", "Correlation_ID:", - req.headers['x-correlation-id'], + req.headers["x-correlation-id"], "|", "HTTP:", "GET", @@ -153,7 +153,7 @@ router user?._id || "unknown", "|", "Correlation_ID:", - req.headers['x-correlation-id'], + req.headers["x-correlation-id"], "|", "HTTP:", "GET", @@ -248,7 +248,7 @@ router user?._id || "unknown", "|", "Correlation_ID:", - req.headers['x-correlation-id'], + req.headers["x-correlation-id"], "|", "HTTP:", "GET", @@ -350,7 +350,7 @@ router user?._id || "unknown", "|", "Correlation_ID:", - req.headers['x-correlation-id'], + req.headers["x-correlation-id"], "|", "HTTP:", "GET", @@ -371,7 +371,7 @@ router user?._id || "unknown", "|", "Correlation_ID:", - req.headers['x-correlation-id'], + req.headers["x-correlation-id"], "|", "HTTP:", "GET", @@ -428,7 +428,7 @@ router client?._id || "unknown", "|", "Correlation_ID:", - req.headers['x-correlation-id'], + req.headers["x-correlation-id"], "|", "HTTP:", "GET", @@ -509,7 +509,7 @@ router client?._id || "unknown", "|", "Correlation_ID:", - req.headers['x-correlation-id'], + req.headers["x-correlation-id"], "|", "HTTP:", "GET", @@ -530,7 +530,7 @@ router client?._id || "unknown", "|", "Correlation_ID:", - req.headers['x-correlation-id'], + req.headers["x-correlation-id"], "|", "HTTP:", "GET", @@ -579,7 +579,7 @@ router user?._id || "unknown", "|", "Correlation_ID:", - req.headers['x-correlation-id'], + req.headers["x-correlation-id"], "|", "HTTP:", "GET", @@ -591,7 +591,7 @@ router "Started", "|", "Desc:", - "Find a user from list of UUIDs" + "Find a user from list of UUIDs", ); var idents = g_db @@ -616,7 +616,7 @@ router user?._id || "unknown", "|", "Correlation_ID:", - req.headers['x-correlation-id'], + req.headers["x-correlation-id"], "|", "HTTP:", "GET", @@ -637,7 +637,7 @@ router user?._id || "unknown", "|", "Correlation_ID:", - req.headers['x-correlation-id'], + req.headers["x-correlation-id"], "|", "HTTP:", "GET", @@ -674,7 +674,7 @@ router name || "unknown", "|", "Correlation_ID:", - req.headers['x-correlation-id'], + req.headers["x-correlation-id"], "|", "HTTP:", "GET", @@ -726,7 +726,7 @@ router name || "unknown", "|", "Correlation_ID:", - req.headers['x-correlation-id'], + req.headers["x-correlation-id"], "|", "HTTP:", "GET", @@ -747,7 +747,7 @@ router name || "unknown", "|", "Correlation_ID:", - req.headers['x-correlation-id'], + req.headers["x-correlation-id"], "|", "HTTP:", "GET", @@ -792,7 +792,7 @@ router client?._id || "unknown", "|", "Correlation_ID:", - req.headers['x-correlation-id'], + req.headers["x-correlation-id"], "|", "HTTP:", "GET", @@ -833,7 +833,7 @@ router client?._id || "unknown", "|", "Correlation_ID:", - req.headers['x-correlation-id'], + req.headers["x-correlation-id"], "|", "HTTP:", "GET", @@ -854,7 +854,7 @@ router client?._id || "unknown", "|", "Correlation_ID:", - req.headers['x-correlation-id'], + req.headers["x-correlation-id"], "|", "HTTP:", "GET", @@ -900,7 +900,7 @@ router client?._id || "unknown", "|", "Correlation_ID:", - req.headers['x-correlation-id'], + req.headers["x-correlation-id"], "|", "HTTP:", "GET", @@ -940,7 +940,7 @@ router client?._id || "unknown", "|", "Correlation_ID:", - req.headers['x-correlation-id'], + req.headers["x-correlation-id"], "|", "HTTP:", "GET", @@ -961,7 +961,7 @@ router client?._id || "unknown", "|", "Correlation_ID:", - req.headers['x-correlation-id'], + req.headers["x-correlation-id"], "|", "HTTP:", "GET", @@ -1008,7 +1008,7 @@ router user?._id || "unknown", "|", "Correlation_ID:", - req.headers['x-correlation-id'], + req.headers["x-correlation-id"], "|", "HTTP:", "GET", @@ -1038,7 +1038,7 @@ router user?._id || "unknown", "|", "Correlation_ID:", - req.headers['x-correlation-id'], + req.headers["x-correlation-id"], "|", "HTTP:", "GET", @@ -1066,7 +1066,7 @@ router user?._id || "unknown", "|", "Correlation_ID:", - req.headers['x-correlation-id'], + req.headers["x-correlation-id"], "|", "HTTP:", "GET", @@ -1087,7 +1087,7 @@ router user?._id || "unknown", "|", "Correlation_ID:", - req.headers['x-correlation-id'], + req.headers["x-correlation-id"], "|", "HTTP:", "GET", @@ -1125,7 +1125,7 @@ router uid || "unknown", "|", "Correlation_ID:", - req.headers['x-correlation-id'], + req.headers["x-correlation-id"], "|", "HTTP:", "GET", @@ -1147,7 +1147,7 @@ router uid || "unknown", "|", "Correlation_ID:", - req.headers['x-correlation-id'], + req.headers["x-correlation-id"], "|", "HTTP:", "GET", @@ -1168,7 +1168,7 @@ router uid || "unknown", "|", "Correlation_ID:", - req.headers['x-correlation-id'], + req.headers["x-correlation-id"], "|", "HTTP:", "GET", @@ -1211,7 +1211,7 @@ router client?._id || "unknown", "|", "Correlation_ID:", - req.headers['x-correlation-id'], + req.headers["x-correlation-id"], "|", "HTTP:", "GET", @@ -1346,7 +1346,7 @@ router client?._id || "unknown", "|", "Correlation_ID:", - req.headers['x-correlation-id'], + req.headers["x-correlation-id"], "|", "HTTP:", "GET", @@ -1370,7 +1370,7 @@ router client?._id || "unknown", "|", "Correlation_ID:", - req.headers['x-correlation-id'], + req.headers["x-correlation-id"], "|", "HTTP:", "GET", @@ -1446,7 +1446,7 @@ router user?._id || "unknown", "|", "Correlation_ID:", - req.headers['x-correlation-id'], + req.headers["x-correlation-id"], "|", "HTTP:", "GET", @@ -1483,7 +1483,7 @@ router user?._id || "unknown", "|", "Correlation_ID:", - req.headers['x-correlation-id'], + req.headers["x-correlation-id"], "|", "HTTP:", "GET", @@ -1503,7 +1503,7 @@ router user?._id || "unknown", "|", "Correlation_ID:", - req.headers['x-correlation-id'], + req.headers["x-correlation-id"], "|", "HTTP:", "GET", @@ -1562,7 +1562,7 @@ router user?._id || "unknown", "|", "Correlation_ID:", - req.headers['x-correlation-id'], + req.headers["x-correlation-id"], "|", "HTTP:", "GET", @@ -1585,7 +1585,7 @@ router user?._id || "unknown", "|", "Correlation_ID:", - req.headers['x-correlation-id'], + req.headers["x-correlation-id"], "|", "HTTP:", "GET", @@ -1605,7 +1605,7 @@ router user?._id || "unknown", "|", "Correlation_ID:", - req.headers['x-correlation-id'], + req.headers["x-correlation-id"], "|", "HTTP:", "GET", @@ -1643,7 +1643,7 @@ router user?._id || "unknown", "|", "Correlation_ID:", - req.headers['x-correlation-id'], + req.headers["x-correlation-id"], "|", "HTTP:", "GET", @@ -1670,7 +1670,7 @@ router user?._id || "unknown", "|", "Correlation_ID:", - req.headers['x-correlation-id'], + req.headers["x-correlation-id"], "|", "HTTP:", "GET", @@ -1690,7 +1690,7 @@ router user?._id || "unknown", "|", "Correlation_ID:", - req.headers['x-correlation-id'], + req.headers["x-correlation-id"], "|", "HTTP:", "GET", @@ -1728,7 +1728,7 @@ router client?._id || "unknown", "|", "Correlation_ID:", - req.headers['x-correlation-id'], + req.headers["x-correlation-id"], "|", "HTTP:", "GET", @@ -1827,7 +1827,7 @@ router client?._id || "unknown", "|", "Correlation_ID:", - req.headers['x-correlation-id'], + req.headers["x-correlation-id"], "|", "HTTP:", "GET", @@ -1848,7 +1848,7 @@ router client?._id || "unknown", "|", "Correlation_ID:", - req.headers['x-correlation-id'], + req.headers["x-correlation-id"], "|", "HTTP:", "GET", @@ -1886,7 +1886,7 @@ router client?._id || "unknown", "|", "Correlation_ID:", - req.headers['x-correlation-id'], + req.headers["x-correlation-id"], "|", "HTTP:", "GET", @@ -1936,7 +1936,7 @@ router client?._id || "unknown", "|", "Correlation_ID:", - req.headers['x-correlation-id'], + req.headers["x-correlation-id"], "|", "HTTP:", "GET", @@ -1965,7 +1965,7 @@ router client?._id || "unknown", "|", "Correlation_ID:", - req.headers['x-correlation-id'], + req.headers["x-correlation-id"], "|", "HTTP:", "GET", @@ -2025,7 +2025,7 @@ router client?._id || "unknown", "|", "Correlation_ID:", - req.headers['x-correlation-id'], + req.headers["x-correlation-id"], "|", "HTTP:", "GET", @@ -2087,7 +2087,7 @@ router client?._id || "unknown", "|", "Correlation_ID:", - req.headers['x-correlation-id'], + req.headers["x-correlation-id"], "|", "HTTP:", "GET", @@ -2172,7 +2172,7 @@ router client?._id || "unknown", "|", "Correlation_ID:", - req.headers['x-correlation-id'], + req.headers["x-correlation-id"], "|", "HTTP:", "GET", @@ -2192,7 +2192,7 @@ router client?._id || "unknown", "|", "Correlation_ID:", - req.headers['x-correlation-id'], + req.headers["x-correlation-id"], "|", "HTTP:", "GET", @@ -2230,7 +2230,7 @@ router client?._id || "unknown", "|", "Correlation_ID:", - req.headers['x-correlation-id'], + req.headers["x-correlation-id"], "|", "HTTP:", "GET", @@ -2264,7 +2264,7 @@ router client?._id || "unknown", "|", "Correlation_ID:", - req.headers['x-correlation-id'], + req.headers["x-correlation-id"], "|", "HTTP:", "GET", @@ -2289,7 +2289,7 @@ router client?._id || "unknown", "|", "Correlation_ID:", - req.headers['x-correlation-id'], + req.headers["x-correlation-id"], "|", "HTTP:", "GET", @@ -2310,7 +2310,7 @@ router client?._id || "unknown", "|", "Correlation_ID:", - req.headers['x-correlation-id'], + req.headers["x-correlation-id"], "|", "HTTP:", "GET", @@ -2353,7 +2353,7 @@ router client?._id || "unknown", "|", "Correlation_ID:", - req.headers['x-correlation-id'], + req.headers["x-correlation-id"], "|", "HTTP:", "GET", @@ -2380,7 +2380,7 @@ router client?._id || "unknown", "|", "Correlation_ID:", - req.headers['x-correlation-id'], + req.headers["x-correlation-id"], "|", "HTTP:", "GET", @@ -2426,7 +2426,7 @@ router client?._id || "unknown", "|", "Correlation_ID:", - req.headers['x-correlation-id'], + req.headers["x-correlation-id"], "|", "HTTP:", "GET", @@ -2486,7 +2486,7 @@ router client?._id || "unknown", "|", "Correlation_ID:", - req.headers['x-correlation-id'], + req.headers["x-correlation-id"], "|", "HTTP:", "GET", @@ -2506,7 +2506,7 @@ router client?._id || "unknown", "|", "Correlation_ID:", - req.headers['x-correlation-id'], + req.headers["x-correlation-id"], "|", "HTTP:", "GET", @@ -2556,7 +2556,7 @@ router client?._id || "unknown", "|", "Correlation_ID:", - req.headers['x-correlation-id'], + req.headers["x-correlation-id"], "|", "HTTP:", "GET", @@ -2588,7 +2588,7 @@ router client?._id || "unknown", "|", "Correlation_ID:", - req.headers['x-correlation-id'], + req.headers["x-correlation-id"], "|", "HTTP:", "GET", @@ -2608,7 +2608,7 @@ router client?._id || "unknown", "|", "Correlation_ID:", - req.headers['x-correlation-id'], + req.headers["x-correlation-id"], "|", "HTTP:", "GET", @@ -2646,7 +2646,7 @@ router client?._id || "unknown", "|", "Correlation_ID:", - req.headers['x-correlation-id'], + req.headers["x-correlation-id"], "|", "HTTP:", "GET", @@ -2667,7 +2667,7 @@ router client?._id || "unknown", "|", "Correlation_ID:", - req.headers['x-correlation-id'], + req.headers["x-correlation-id"], "|", "HTTP:", "GET", @@ -2687,7 +2687,7 @@ router client?._id || "unknown", "|", "Correlation_ID:", - req.headers['x-correlation-id'], + req.headers["x-correlation-id"], "|", "HTTP:", "GET", @@ -2724,7 +2724,7 @@ router client?._id || "unknown", "|", "Correlation_ID:", - req.headers['x-correlation-id'], + req.headers["x-correlation-id"], "|", "HTTP:", "GET", @@ -2753,7 +2753,7 @@ router client?._id || "unknown", "|", "Correlation_ID:", - req.headers['x-correlation-id'], + req.headers["x-correlation-id"], "|", "HTTP:", "GET", @@ -2773,7 +2773,7 @@ router client?._id || "unknown", "|", "Correlation_ID:", - req.headers['x-correlation-id'], + req.headers["x-correlation-id"], "|", "HTTP:", "GET", From e6672a5f612a2e925b77827153fafcee6c8f0633 Mon Sep 17 00:00:00 2001 From: Austin Hampton Date: Thu, 4 Sep 2025 07:49:28 -0400 Subject: [PATCH 07/36] refactor: First pass of logging within user_router.js --- core/database/foxx/api/user_router.js | 139 +++++++++++++++++++++++++- 1 file changed, 135 insertions(+), 4 deletions(-) diff --git a/core/database/foxx/api/user_router.js b/core/database/foxx/api/user_router.js index f1169862b..203374c29 100644 --- a/core/database/foxx/api/user_router.js +++ b/core/database/foxx/api/user_router.js @@ -260,8 +260,18 @@ router "Started", "|", "Desc:", - "Creating new user entry", + "Creating new user entry:", "|", + "Name:", + req.queryParams.name, + "Email:", + req.queryParams.email, + "Options:", + req.queryParams.options, + "uuid:", + req.queryParams.uuids, + "is_admin:", + req.queryParams.is_admin ); var root = g_db.c.save( @@ -364,6 +374,16 @@ router "Desc:", "Create new user entry", "|", + "Name:", + req.queryParams.name, + "Email:", + req.queryParams.email, + "Options:", + req.queryParams.options, + "uuid:", + req.queryParams.uuids, + "is_admin:", + req.queryParams.is_admin ); } catch (e) { console.error( @@ -385,6 +405,16 @@ router "Desc:", "Create new user entry", "|", + "Name:", + req.queryParams.name, + "Email:", + req.queryParams.email, + "Options:", + req.queryParams.options, + "uuid:", + req.queryParams.uuids, + "is_admin:", + req.queryParams.is_admin, "Err:", e.message || e, "|", @@ -421,7 +451,7 @@ router write: ["u", "admin"], }, action: function () { - client = g_lib.getUserFromClientID(req.queryParams.client); + client = g_lib.getUserFromClientID(req.queryParams.client); var user_id; console.info( "Client:", @@ -442,6 +472,16 @@ router "Desc:", "Updating user information", "|", + "Name:", + req.queryParams.name, + "Email:", + req.queryParams.email, + "Options:", + req.queryParams.options, + "uuid:", + req.queryParams.uuids, + "is_admin:", + req.queryParams.is_admin, ); if (req.queryParams.subject) { user_id = req.queryParams.subject; @@ -523,6 +563,16 @@ router "Desc:", "Updating user information", "|", + "Name:", + req.queryParams.name, + "Email:", + req.queryParams.email, + "Options:", + req.queryParams.options, + "uuid:", + req.queryParams.uuids, + "is_admin:", + req.queryParams.is_admin, ); } catch (e) { console.error( @@ -544,6 +594,16 @@ router "Desc:", "Updating user information", "|", + "Name:", + req.queryParams.name, + "Email:", + req.queryParams.email, + "Options:", + req.queryParams.options, + "uuid:", + req.queryParams.uuids, + "is_admin:", + req.queryParams.is_admin, "Err:", e.message || e, "|", @@ -592,6 +652,9 @@ router "|", "Desc:", "Find a user from list of UUIDs", + "|", + "UUIDs:", + req.queryParams.uuids ); var idents = g_db @@ -630,6 +693,8 @@ router "Desc:", "Find a user from list of UUIDs", "|", + "UUIDs:", + req.queryParams.uuids ); } catch (e) { console.error( @@ -651,6 +716,8 @@ router "Desc:", "Find a user from list of UUIDs", "|", + "User_UID:", + req.queryParams.uuids, "Err:", e.message || e, "|", @@ -1741,8 +1808,10 @@ router "|", "Desc:", "View User Information", + "|", + "Details:", + req.queryParams.details ); - var user, det_ok = false; @@ -1840,6 +1909,9 @@ router "|", "Desc:", "View User Information", + "|", + "Detail:", + req.queryParams.details ); } catch (e) { g_lib.handleException(e, res); @@ -1862,6 +1934,9 @@ router "Desc:", "View User Information", "|", + "Detail", + req.queryParams.details, + "|", "Err:", e.message || e, "|", @@ -2100,6 +2175,9 @@ router "|", "Desc:", "Remove existing user entry", + "|", + "Removed user:", + user_id ); if (req.queryParams.subject) { @@ -2185,6 +2263,9 @@ router "|", "Desc:", "Remove existing user entry", + "|", + "Removed user:", + user_id ); } catch (e) { console.error( @@ -2206,6 +2287,9 @@ router "Desc:", "Remove existing user entry", "|", + "Removed user:", + user_id, + "|", "Err:", e.message || e, "|", @@ -2366,6 +2450,10 @@ router "|", "Desc:", "Add new linked identity", + "|", + "Identity:", + req.queryParams.ident, + ); var id; @@ -2393,6 +2481,10 @@ router "|", "Desc:", "Add new linked identity", + "|", + "Identity:", + req.queryParams.ident, + ); return; id = g_db.uuid.save( @@ -2439,6 +2531,9 @@ router "|", "Desc:", "Add new linked identity", + "|", + "Identity:", + req.queryParams.ident, ); return; } else { @@ -2498,7 +2593,10 @@ router "Success", "|", "Desc:", - "Add new linked identity", + "Add new linked identity:", + "|", + "Identity:", + req.queryParams.ident, ); } catch (e) { console.error( @@ -2520,6 +2618,9 @@ router "Desc:", "Add new linked identity", "|", + "Identity:", + req.queryParams.ident, + "|", "Err:", e.message || e, "|", @@ -2569,6 +2670,9 @@ router "|", "Desc:", "Remove linked identity from user account", + "|", + "Identity:", + req.queryParams.ident ); g_lib.ensureAdminPermUser(client, owner._id); @@ -2601,6 +2705,9 @@ router "|", "Desc:", "Remove linked identity from user account", + "|", + "Identity:", + req.queryParams.ident ); } catch (e) { console.error( @@ -2622,6 +2729,9 @@ router "Desc:", "Remove linked identity from user account", "|", + "Identity:", + req.queryParams.ident, + "|", "Err:", e.message || e, "|", @@ -2659,6 +2769,9 @@ router "|", "Desc:", "Get recent end-points", + "|", + "End-points:", + client.eps ); res.send(client.eps ? client.eps : []); @@ -2680,6 +2793,10 @@ router "|", "Desc:", "Get recent end-points", + "|", + "End-points:", + client.eps + ); } catch (e) { console.error( @@ -2701,6 +2818,9 @@ router "Desc:", "Get recent end-points", "|", + "End-points:", + client.eps, + "|", "Err:", e.message || e, "|", @@ -2737,6 +2857,10 @@ router "|", "Desc:", "Set recent end-points", + "|", + "End-points:", + client.eps + ); g_db._update( @@ -2766,6 +2890,10 @@ router "|", "Desc:", "Set recent end-points", + "|", + "End-points:", + client.eps + ); } catch (e) { console.error( @@ -2787,6 +2915,9 @@ router "Desc:", "Set recent end-points", "|", + "End-points:", + client.eps, + "|", "Err:", e.message || e, "|", From cd74489fcf20aee38bde66d264bf3bb8d831c94f Mon Sep 17 00:00:00 2001 From: Austin Hampton Date: Thu, 4 Sep 2025 11:52:34 -0400 Subject: [PATCH 08/36] refactor: last minute changes --- core/database/foxx/api/user_router.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/core/database/foxx/api/user_router.js b/core/database/foxx/api/user_router.js index 203374c29..a7ae54c6c 100644 --- a/core/database/foxx/api/user_router.js +++ b/core/database/foxx/api/user_router.js @@ -973,7 +973,7 @@ router "GET", "|", "Route:", - "/keys/set", + "/keys/clear", "|", "Status:", "Started", @@ -1013,7 +1013,7 @@ router "GET", "|", "Route:", - "/keys/set", + "/keys/clear", "|", "Status:", "Success", @@ -1034,7 +1034,7 @@ router "GET", "|", "Route:", - "/keys/set", + "/keys/clear", "|", "Status:", "Failure", From 483ffe4169003ffd0484f9f51dbb552e88f9ed01 Mon Sep 17 00:00:00 2001 From: Austin Hampton Date: Thu, 4 Sep 2025 11:50:43 +0000 Subject: [PATCH 09/36] chore: Auto-format JavaScript files with Prettier --- core/database/foxx/api/user_router.js | 35 ++++++++++++--------------- 1 file changed, 15 insertions(+), 20 deletions(-) diff --git a/core/database/foxx/api/user_router.js b/core/database/foxx/api/user_router.js index a7ae54c6c..c44f5edf7 100644 --- a/core/database/foxx/api/user_router.js +++ b/core/database/foxx/api/user_router.js @@ -271,7 +271,7 @@ router "uuid:", req.queryParams.uuids, "is_admin:", - req.queryParams.is_admin + req.queryParams.is_admin, ); var root = g_db.c.save( @@ -383,7 +383,7 @@ router "uuid:", req.queryParams.uuids, "is_admin:", - req.queryParams.is_admin + req.queryParams.is_admin, ); } catch (e) { console.error( @@ -451,7 +451,7 @@ router write: ["u", "admin"], }, action: function () { - client = g_lib.getUserFromClientID(req.queryParams.client); + client = g_lib.getUserFromClientID(req.queryParams.client); var user_id; console.info( "Client:", @@ -654,7 +654,7 @@ router "Find a user from list of UUIDs", "|", "UUIDs:", - req.queryParams.uuids + req.queryParams.uuids, ); var idents = g_db @@ -694,7 +694,7 @@ router "Find a user from list of UUIDs", "|", "UUIDs:", - req.queryParams.uuids + req.queryParams.uuids, ); } catch (e) { console.error( @@ -1810,7 +1810,7 @@ router "View User Information", "|", "Details:", - req.queryParams.details + req.queryParams.details, ); var user, det_ok = false; @@ -1911,7 +1911,7 @@ router "View User Information", "|", "Detail:", - req.queryParams.details + req.queryParams.details, ); } catch (e) { g_lib.handleException(e, res); @@ -2177,7 +2177,7 @@ router "Remove existing user entry", "|", "Removed user:", - user_id + user_id, ); if (req.queryParams.subject) { @@ -2265,7 +2265,7 @@ router "Remove existing user entry", "|", "Removed user:", - user_id + user_id, ); } catch (e) { console.error( @@ -2453,7 +2453,6 @@ router "|", "Identity:", req.queryParams.ident, - ); var id; @@ -2484,7 +2483,6 @@ router "|", "Identity:", req.queryParams.ident, - ); return; id = g_db.uuid.save( @@ -2672,7 +2670,7 @@ router "Remove linked identity from user account", "|", "Identity:", - req.queryParams.ident + req.queryParams.ident, ); g_lib.ensureAdminPermUser(client, owner._id); @@ -2707,7 +2705,7 @@ router "Remove linked identity from user account", "|", "Identity:", - req.queryParams.ident + req.queryParams.ident, ); } catch (e) { console.error( @@ -2771,7 +2769,7 @@ router "Get recent end-points", "|", "End-points:", - client.eps + client.eps, ); res.send(client.eps ? client.eps : []); @@ -2795,8 +2793,7 @@ router "Get recent end-points", "|", "End-points:", - client.eps - + client.eps, ); } catch (e) { console.error( @@ -2859,8 +2856,7 @@ router "Set recent end-points", "|", "End-points:", - client.eps - + client.eps, ); g_db._update( @@ -2892,8 +2888,7 @@ router "Set recent end-points", "|", "End-points:", - client.eps - + client.eps, ); } catch (e) { console.error( From a61af8bb5f7b3edf0c57dce5f8e5f0149ebc6a75 Mon Sep 17 00:00:00 2001 From: Austin Hampton Date: Tue, 16 Sep 2025 10:50:28 -0400 Subject: [PATCH 10/36] Refactor: Added second pass of logging to user router --- core/database/foxx/api/user_router.js | 2160 ++++++++----------------- 1 file changed, 642 insertions(+), 1518 deletions(-) diff --git a/core/database/foxx/api/user_router.js b/core/database/foxx/api/user_router.js index c44f5edf7..978fc2154 100644 --- a/core/database/foxx/api/user_router.js +++ b/core/database/foxx/api/user_router.js @@ -10,6 +10,8 @@ const g_graph = require("@arangodb/general-graph")._graph("sdmsg"); const g_lib = require("./support"); const { UserToken } = require("./lib/user_token"); const { UserModel } = require("./models/user"); +const logger = require("./lib/logger") +const basePath = "usr" module.exports = router; @@ -183,8 +185,8 @@ router router .get("/create", function (req, res) { let user = undefined; + let result = undefined; try { - var result; g_db._executeTransaction({ collections: { @@ -243,37 +245,15 @@ router user = g_db.u.save(user_data, { returnNew: true, }); - console.info( - "Client:", - user?._id || "unknown", - "|", - "Correlation_ID:", - req.headers["x-correlation-id"], - "|", - "HTTP:", - "GET", - "|", - "Route:", - "/create", - "|", - "Status:", - "Started", - "|", - "Desc:", - "Creating new user entry:", - "|", - "Name:", - req.queryParams.name, - "Email:", - req.queryParams.email, - "Options:", - req.queryParams.options, - "uuid:", - req.queryParams.uuids, - "is_admin:", - req.queryParams.is_admin, - ); - + logger.logRequestStarted({ + client: user?._id, + correlationId: req.headers["x-correlation-id"], + httpVerb: "GET", + routePath: basePath + "/create", + status: "Started", + description: "Create new user entry", + }); + var root = g_db.c.save( { _key: "u_" + req.queryParams.uid + "_root", @@ -355,74 +335,29 @@ router }, }); res.send(result); - console.info( - "Client:", - user?._id || "unknown", - "|", - "Correlation_ID:", - req.headers["x-correlation-id"], - "|", - "HTTP:", - "GET", - "|", - "Route:", - "/create", - "|", - "Status:", - "Success", - "|", - "Desc:", - "Create new user entry", - "|", - "Name:", - req.queryParams.name, - "Email:", - req.queryParams.email, - "Options:", - req.queryParams.options, - "uuid:", - req.queryParams.uuids, - "is_admin:", - req.queryParams.is_admin, - ); + logger.logRequestSuccess({ + client: user?._id, + correlationId: req.headers["x-correlation-id"], + httpVerb: "GET", + routePath: basePath + "/create", + status: "Success", + description: "Create new user entry", + extra: result + }); } catch (e) { - console.error( - "Client:", - user?._id || "unknown", - "|", - "Correlation_ID:", - req.headers["x-correlation-id"], - "|", - "HTTP:", - "GET", - "|", - "Route:", - "/create", - "|", - "Status:", - "Failure", - "|", - "Desc:", - "Create new user entry", - "|", - "Name:", - req.queryParams.name, - "Email:", - req.queryParams.email, - "Options:", - req.queryParams.options, - "uuid:", - req.queryParams.uuids, - "is_admin:", - req.queryParams.is_admin, - "Err:", - e.message || e, - "|", - "Stack:", - e.stack || "No Stack Trace", - ); + logger.logRequestFailure({ + client: user?._id, + correlationId: req.headers["x-correlation-id"], + httpVerb: "GET", + routePath: basePath + "/create", + status: "Failure", + description: "Create new user entry", + extra: result, + message: e.message, + stack: e.stack + }); g_lib.handleException(e, res); - } + } }) .queryParam( "secret", @@ -442,8 +377,16 @@ router router .get("/update", function (req, res) { let client = undefined; + let result = undefined; try { - var result; + logger.logRequestStarted({ + client: user?._id, + correlationId: req.headers["x-correlation-id"], + httpVerb: "GET", + routePath: basePath + "/create", + status: "Started", + description: "Create new user entry", + }); g_db._executeTransaction({ collections: { @@ -453,36 +396,15 @@ router action: function () { client = g_lib.getUserFromClientID(req.queryParams.client); var user_id; - console.info( - "Client:", - client?._id || "unknown", - "|", - "Correlation_ID:", - req.headers["x-correlation-id"], - "|", - "HTTP:", - "GET", - "|", - "Route:", - "/update", - "|", - "Status:", - "Started", - "|", - "Desc:", - "Updating user information", - "|", - "Name:", - req.queryParams.name, - "Email:", - req.queryParams.email, - "Options:", - req.queryParams.options, - "uuid:", - req.queryParams.uuids, - "is_admin:", - req.queryParams.is_admin, - ); + logger.logRequestStarted({ + client: client?._id, + correlationId: req.headers["x-correlation-id"], + httpVerb: "GET", + routePath: basePath + "/update", + status: "Started", + description: "Update user information", + }); + if (req.queryParams.subject) { user_id = req.queryParams.subject; if (!g_db.u.exists(user_id)) @@ -542,74 +464,28 @@ router result = [user.new]; }, }); - - res.send(result); - console.info( - "Client:", - client?._id || "unknown", - "|", - "Correlation_ID:", - req.headers["x-correlation-id"], - "|", - "HTTP:", - "GET", - "|", - "Route:", - "/update", - "|", - "Status:", - "Success", - "|", - "Desc:", - "Updating user information", - "|", - "Name:", - req.queryParams.name, - "Email:", - req.queryParams.email, - "Options:", - req.queryParams.options, - "uuid:", - req.queryParams.uuids, - "is_admin:", - req.queryParams.is_admin, - ); - } catch (e) { - console.error( - "Client:", - client?._id || "unknown", - "|", - "Correlation_ID:", - req.headers["x-correlation-id"], - "|", - "HTTP:", - "GET", - "|", - "Route:", - "/update", - "|", - "Status:", - "Failure", - "|", - "Desc:", - "Updating user information", - "|", - "Name:", - req.queryParams.name, - "Email:", - req.queryParams.email, - "Options:", - req.queryParams.options, - "uuid:", - req.queryParams.uuids, - "is_admin:", - req.queryParams.is_admin, - "Err:", - e.message || e, - "|", - "Stack:", - e.stack || "No Stack Trace", - ); + logger.logRequestSuccess({ + client: client?._id, + correlationId: req.headers["x-correlation-id"], + httpVerb: "GET", + routePath: basePath + "/update", + status: "Success", + description: "Update user information", + extra: result + }); + } catch (e) { + + logger.logRequestFailure({ + client: client?._id, + correlationId: req.headers["x-correlation-id"], + httpVerb: "GET", + routePath: basePath + "/update", + status: "Failure", + description: "Update user information", + extra: result, + message: e.message, + stack: e.stack + }); g_lib.handleException(e, res); } }) @@ -634,29 +510,14 @@ router } user = g_lib.findUserFromUUIDs(uuids); - console.info( - "Client:", - user?._id || "unknown", - "|", - "Correlation_ID:", - req.headers["x-correlation-id"], - "|", - "HTTP:", - "GET", - "|", - "Route:", - "/find/by_uuids", - "|", - "Status:", - "Started", - "|", - "Desc:", - "Find a user from list of UUIDs", - "|", - "UUIDs:", - req.queryParams.uuids, - ); - + logger.logRequestStarted({ + client: user?._id, + correlationId: req.headers["x-correlation-id"], + httpVerb: "GET", + routePath: basePath + "/find/by_uuids", + status: "Started", + description: "Find a user from list of UUIDs", + }); var idents = g_db ._query("for v in 1..1 outbound @user ident return v._key", { user: user._id, @@ -674,56 +535,28 @@ router delete user.name; res.send([user]); - console.info( - "Client:", - user?._id || "unknown", - "|", - "Correlation_ID:", - req.headers["x-correlation-id"], - "|", - "HTTP:", - "GET", - "|", - "Route:", - "/find/by_uuids", - "|", - "Status:", - "Success", - "|", - "Desc:", - "Find a user from list of UUIDs", - "|", - "UUIDs:", - req.queryParams.uuids, - ); - } catch (e) { - console.error( - "Client:", - user?._id || "unknown", - "|", - "Correlation_ID:", - req.headers["x-correlation-id"], - "|", - "HTTP:", - "GET", - "|", - "Route:", - "/find/by_uuids", - "|", - "Status:", - "Failure", - "|", - "Desc:", - "Find a user from list of UUIDs", - "|", - "User_UID:", - req.queryParams.uuids, - "Err:", - e.message || e, - "|", - "Stack:", - e.stack || "No Stack Trace", - ); + logger.logRequestSuccess({ + client: user?._id, + correlationId: req.headers["x-correlation-id"], + httpVerb: "GET", + routePath: basePath + "/find/by_uuids", + status: "Started", + description: "Find a user from list of UUIDs", + extra: req.queryParams.uuids + }); + } catch (e) { + + logger.logRequestFailure({ + client: user?._id, + correlationId: req.headers["x-correlation-id"], + httpVerb: "GET", + routePath: basePath + "/find/by_uuids", + status: "Failure", + description: "Find a user from list of UUIDs", + extra: req.queryParams.uuids, + message: e.message, + stack: e.stack + }); g_lib.handleException(e, res); } }) @@ -736,26 +569,14 @@ router let name = undefined; try { name = req.queryParams.name_uid.trim(); - console.info( - "Client:", - name || "unknown", - "|", - "Correlation_ID:", - req.headers["x-correlation-id"], - "|", - "HTTP:", - "GET", - "|", - "Route:", - "/find/by_name_uid", - "|", - "Status:", - "Started", - "|", - "Desc:", - "Find a user from list of UUIDs", - "|", - ); + logger.logRequestStarted({ + client: name, + correlationId: req.headers["x-correlation-id"], + httpVerb: "GET", + routePath: basePath + "/find/by_name_uid", + status: "Started", + description: "Find users matching partial name and/or uid", + }); if (name.length < 2) throw [g_lib.ERR_INVALID_PARAM, "Input is too short for name/uid search."]; @@ -788,52 +609,27 @@ router }); res.send(result); - console.info( - "Client:", - name || "unknown", - "|", - "Correlation_ID:", - req.headers["x-correlation-id"], - "|", - "HTTP:", - "GET", - "|", - "Route:", - "/find/by_name_uid", - "|", - "Status:", - "Success", - "|", - "Desc:", - "Find users matching partial name and/or uid", - "|", - ); - } catch (e) { - console.error( - "Client:", - name || "unknown", - "|", - "Correlation_ID:", - req.headers["x-correlation-id"], - "|", - "HTTP:", - "GET", - "|", - "Route:", - "/find/by_name_uid", - "|", - "Status:", - "Failure", - "|", - "Desc:", - "Find users matching partial name and/or uid", - "|", - "Err:", - e.message || e, - "|", - "Stack:", - e.stack || "No Stack Trace", - ); + logger.logRequestSuccess({ + client: name, + correlationId: req.headers["x-correlation-id"], + httpVerb: "GET", + routePath: basePath + "/find/by_name_uid", + status: "Success", + description: "Find users matching partial name and/or uid", + extra: result + }); + } catch (e) { + logger.logRequestFailure({ + client: name, + correlationId: req.headers["x-correlation-id"], + httpVerb: "GET", + routePath: basePath + "/find/by_name_uid", + status: "Failure", + description: "Find users matching partial name and/or uid", + extra: result, + message: e.message, + stack: e.stack + }); g_lib.handleException(e, res); } }) @@ -854,26 +650,15 @@ router }, action: function () { client = g_lib.getUserFromClientID(req.queryParams.client); - console.info( - "Client:", - client?._id || "unknown", - "|", - "Correlation_ID:", - req.headers["x-correlation-id"], - "|", - "HTTP:", - "GET", - "|", - "Route:", - "/keys/set", - "|", - "Status:", - "Started", - "|", - "Desc:", - "Set user public and private keys", - "|", - ); + + logger.logRequestStarted({ + client: client?._id, + correlationId: req.headers["x-correlation-id"], + httpVerb: "GET", + routePath: basePath + "/keys/set", + status: "Started", + description: "Set user public and private keys", + }); var user_id; @@ -895,52 +680,28 @@ router }); }, }); - console.info( - "Client:", - client?._id || "unknown", - "|", - "Correlation_ID:", - req.headers["x-correlation-id"], - "|", - "HTTP:", - "GET", - "|", - "Route:", - "/keys/set", - "|", - "Status:", - "Success", - "|", - "Desc:", - "Set user public and private keys", - "|", - ); - } catch (e) { - console.error( - "Client:", - client?._id || "unknown", - "|", - "Correlation_ID:", - req.headers["x-correlation-id"], - "|", - "HTTP:", - "GET", - "|", - "Route:", - "/keys/set", - "|", - "Status:", - "Failure", - "|", - "Desc:", - "Set user public and private keys", - "|", - "Err:", - e.message || e, - "|", - "Stack:", - e.stack || "No Stack Trace", - ); + + logger.logRequestSuccess({ + client: client?._id, + correlationId: req.headers["x-correlation-id"], + httpVerb: "GET", + routePath: basePath + "/keys/set", + status: "Success", + description: "Set user public and private keys", + extra: "undefined", + }); + } catch (e) { + logger.logRequestFailure({ + client: client?._id, + correlationId: req.headers["x-correlation-id"], + httpVerb: "GET", + routePath: basePath + "/keys/set", + status: "Failure", + description: "Set user public and private keys", + extra: "undefined", + message: e.message, + stack: e.stack + }); g_lib.handleException(e, res); } }) @@ -961,27 +722,16 @@ router write: ["u"], }, action: function () { - client = g_lib.getUserFromClientID(req.queryParams.client); - console.info( - "Client:", - client?._id || "unknown", - "|", - "Correlation_ID:", - req.headers["x-correlation-id"], - "|", - "HTTP:", - "GET", - "|", - "Route:", - "/keys/clear", - "|", - "Status:", - "Started", - "|", - "Desc:", - "Clear user public and private keys", - "|", - ); + client = g_lib.getUserFromClientID(req.queryParams.client); + logger.logRequestStarted({ + client: client?._id, + correlationId: req.headers["x-correlation-id"], + httpVerb: "GET", + routePath: basePath + "/keys/clear", + status: "Started", + description: "Clear user public and private keys", + }); + var user_id; if (req.queryParams.subject) { @@ -1002,52 +752,27 @@ router }); }, }); - console.info( - "Client:", - client?._id || "unknown", - "|", - "Correlation_ID:", - req.headers["x-correlation-id"], - "|", - "HTTP:", - "GET", - "|", - "Route:", - "/keys/clear", - "|", - "Status:", - "Success", - "|", - "Desc:", - "Clear user public and private keys", - "|", - ); + logger.logRequestSuccess({ + client: client?._id, + correlationId: req.headers["x-correlation-id"], + httpVerb: "GET", + routePath: basePath + "/keys/clear", + status: "Success", + description: "Clear user public and private keys", + extra: "undefined", + }); } catch (e) { - console.error( - "Client:", - client?._id || "unknown", - "|", - "Correlation_ID:", - req.headers["x-correlation-id"], - "|", - "HTTP:", - "GET", - "|", - "Route:", - "/keys/clear", - "|", - "Status:", - "Failure", - "|", - "Desc:", - "Clear user public and private keys", - "|", - "Err:", - e.message || e, - "|", - "Stack:", - e.stack || "No Stack Trace", - ); + logger.logRequestFailure({ + client: client?._id, + correlationId: req.headers["x-correlation-id"], + httpVerb: "GET", + routePath: basePath + "/keys/clear", + status: "Failure", + description: "Clear user public and private keys", + extra: "undefined", + message: e.message, + stack: e.stack + }); g_lib.handleException(e, res); } }) @@ -1070,26 +795,14 @@ router user = g_db.u.document({ _id: req.queryParams.subject, }); - console.info( - "Client:", - user?._id || "unknown", - "|", - "Correlation_ID:", - req.headers["x-correlation-id"], - "|", - "HTTP:", - "GET", - "|", - "Route:", - "/keys/get", - "|", - "Status:", - "Started", - "|", - "Desc:", - "Get user public and private keys", - "|", - ); + logger.logRequestStarted({ + client: user?._id, + correlationId: req.headers["x-correlation-id"], + httpVerb: "GET", + routePath: basePath + "/keys/get", + status: "Started", + description: "Get user public and private keys", + }); } else { user = g_lib.getUserFromClientID(req.queryParams.client); } @@ -1100,26 +813,15 @@ router uid: user._id, }, ]); - console.info( - "Client:", - user?._id || "unknown", - "|", - "Correlation_ID:", - req.headers["x-correlation-id"], - "|", - "HTTP:", - "GET", - "|", - "Route:", - "/keys/get", - "|", - "Status:", - "Success", - "|", - "Desc:", - "Get user public and private keys", - "|", - ); + logger.logRequestSuccess({ + client: user?._id, + correlationId: req.headers["x-correlation-id"], + httpVerb: "GET", + routePath: basePath + "/keys/get", + status: "Success", + description: "Get user public and private keys", + extra: "undefined", + }); } else res.send([ { @@ -1128,52 +830,27 @@ router priv_key: user.priv_key, }, ]); - console.info( - "Client:", - user?._id || "unknown", - "|", - "Correlation_ID:", - req.headers["x-correlation-id"], - "|", - "HTTP:", - "GET", - "|", - "Route:", - "/keys/get", - "|", - "Status:", - "Success", - "|", - "Desc:", - "Get user public and private keys", - "|", - ); - } catch (e) { - console.error( - "Client:", - user?._id || "unknown", - "|", - "Correlation_ID:", - req.headers["x-correlation-id"], - "|", - "HTTP:", - "GET", - "|", - "Route:", - "/keys/get", - "|", - "Status:", - "Failure", - "|", - "Desc:", - "Get user public and private keys", - "|", - "Err:", - e.message || e, - "|", - "Stack:", - e.stack || "No Stack Trace", - ); + logger.logRequestSuccess({ + client: user?._id, + correlationId: req.headers["x-correlation-id"], + httpVerb: "GET", + routePath: basePath + "/keys/get", + status: "Success", + description: "Get user public and private keys", + extra: "undefined", + }); + } catch (e) { + logger.logRequestFailure({ + client: user?._id, + correlationId: req.headers["x-correlation-id"], + httpVerb: "GET", + routePath: basePath + "/keys/get", + status: "Failure", + description: "Get user public and private keys", + extra: "undefined", + message: e.message, + stack: e.stack + }); g_lib.handleException(e, res); } }) @@ -1187,74 +864,36 @@ router let uid = undefined; try { uid = g_lib.uidFromPubKey(req.queryParams.pub_key); - console.info( - "Client:", - uid || "unknown", - "|", - "Correlation_ID:", - req.headers["x-correlation-id"], - "|", - "HTTP:", - "GET", - "|", - "Route:", - "/find/by_pub_key", - "|", - "Status:", - "Started", - "|", - "Desc:", - "Find a user by public key", - "|", - ); - + logger.logRequestStarted({ + client: uid, + correlationId: req.headers["x-correlation-id"], + httpVerb: "GET", + routePath: basePath + "/find/by_pub_key", + status: "Started", + description: "Find a user by public key" + }); res.send(uid); - console.info( - "Client:", - uid || "unknown", - "|", - "Correlation_ID:", - req.headers["x-correlation-id"], - "|", - "HTTP:", - "GET", - "|", - "Route:", - "/find/by_pub_key", - "|", - "Status:", - "Success", - "|", - "Desc:", - "Find a user by public key", - "|", - ); - } catch (e) { - console.error( - "Client:", - uid || "unknown", - "|", - "Correlation_ID:", - req.headers["x-correlation-id"], - "|", - "HTTP:", - "GET", - "|", - "Route:", - "/find/by_pub_key", - "|", - "Status:", - "Failure", - "|", - "Desc:", - "Find a user by public key", - "|", - "Err:", - e.message || e, - "|", - "Stack:", - e.stack || "No Stack Trace", - ); + logger.logRequestSuccess({ + client: uid, + correlationId: req.headers["x-correlation-id"], + httpVerb: "GET", + routePath: basePath + "/find/by_pub_key", + status: "Success", + description: "Find a user by public key", + extra: uid, + }); + } catch (e) { + logger.logRequestFailure({ + client: uid, + correlationId: req.headers["x-correlation-id"], + httpVerb: "GET", + routePath: basePath + "/find/by_pub_key", + status: "Failure", + description: "Find a user by public key", + extra: uid, + message: e.message, + stack: e.stack + }); g_lib.handleException(e, res); } }) @@ -1273,26 +912,15 @@ router }, action: function () { client = g_lib.getUserFromClientID(req.queryParams.client); - console.info( - "Client:", - client?._id || "unknown", - "|", - "Correlation_ID:", - req.headers["x-correlation-id"], - "|", - "HTTP:", - "GET", - "|", - "Route:", - "/token/set", - "|", - "Status:", - "Started", - "|", - "Desc:", - "Setting user token", - "|", - ); + + logger.logRequestStarted({ + client: client?._id, + correlationId: req.headers["x-correlation-id"], + httpVerb: "GET", + routePath: basePath + "/token/set", + status: "Started", + description: "Setting user token" + }); var user_id; let user_doc; @@ -1408,55 +1036,30 @@ router }); break; } - console.info( - "Client:", - client?._id || "unknown", - "|", - "Correlation_ID:", - req.headers["x-correlation-id"], - "|", - "HTTP:", - "GET", - "|", - "Route:", - "/token/set", - "|", - "Status:", - "Success", - "|", - "Desc:", - "Setting user token", - "|", - ); + logger.logRequestSuccess({ + client: client?._id, + correlationId: req.headers["x-correlation-id"], + httpVerb: "GET", + routePath: basePath + "/token/set", + status: "Success", + description: "Setting user token", + extra: "undefined" + }); } }, }); } catch (e) { - console.error( - "Client:", - client?._id || "unknown", - "|", - "Correlation_ID:", - req.headers["x-correlation-id"], - "|", - "HTTP:", - "GET", - "|", - "Route:", - "/token/set", - "|", - "Status:", - "Failure", - "|", - "Desc:", - "Setting user token", - "|", - "Err:", - e.message || e, - "|", - "Stack:", - e.stack || "No Stack Trace", - ); + logger.logRequestFailure({ + client: client?._id, + correlationId: req.headers["x-correlation-id"], + httpVerb: "GET", + routePath: basePath + "/token/set", + status: "Failure", + description: "Setting user tokens", + extra: "undefined", + message: e.message, + stack: e.stack + }); g_lib.handleException(e, res); } }) @@ -1508,25 +1111,14 @@ router user = g_lib.getUserFromClientID(req.queryParams.client); } - console.info( - "Client:", - user?._id || "unknown", - "|", - "Correlation_ID:", - req.headers["x-correlation-id"], - "|", - "HTTP:", - "GET", - "|", - "Route:", - "usr/token/get/", - "|", - "Status:", - "Started", - "|", - "Desc:", - "Getting User Token", - ); + logger.logRequestStarted({ + client: user?._id, + correlationId: req.headers["x-correlation-id"], + httpVerb: "GET", + routePath: basePath + "/token/get", + status: "Started", + description: "Getting user token" + }); const user_token = new UserToken({ user_id: user._id, @@ -1545,51 +1137,26 @@ router ); res.send(result); - console.info( - "Client:", - user?._id || "unknown", - "|", - "Correlation_ID:", - req.headers["x-correlation-id"], - "|", - "HTTP:", - "GET", - "|", - "Route:", - "usr/token/get/", - "|", - "Status:", - "Success", - "|", - "Desc:", - "Getting User Token", - ); + logger.logRequestSuccess({ + client: user?._id, + correlationId: req.headers["x-correlation-id"], + httpVerb: "GET", + routePath: basePath + "/token/get", + status: "Success", + description: "Getting user token" + }); } catch (e) { - console.error( - "Client:", - user?._id || "unknown", - "|", - "Correlation_ID:", - req.headers["x-correlation-id"], - "|", - "HTTP:", - "GET", - "|", - "Route:", - "usr/token/get/", - "|", - "Status:", - "Failure", - "|", - "Desc:", - "Getting User Token", - "|", - "Err:", - e.message || e, - "|", - "Stack:", - e.stack || "No Stack Trace", - ); + logger.logRequestFailure({ + client: user?._id, + correlationId: req.headers["x-correlation-id"], + httpVerb: "GET", + routePath: basePath + "/token/get", + status: "Failure", + description: "Getting user tokens", + extra: "undefined", + message: e.message, + stack: e.stack + }); g_lib.handleException(e, res); } }) @@ -1624,74 +1191,40 @@ router } else { user = g_lib.getUserFromClientID(req.queryParams.client); } - console.info( - "Client:", - user?._id || "unknown", - "|", - "Correlation_ID:", - req.headers["x-correlation-id"], - "|", - "HTTP:", - "GET", - "|", - "Route:", - "/token/get/access", - "|", - "Status:", - "Started", - "|", - "Desc:", - "Getting User Access Token", - ); + logger.logRequestStarted({ + client: user?._id, + correlationId: req.headers["x-correlation-id"], + httpVerb: "GET", + routePath: basePath + "/token/get/access", + status: "Started", + description: "Getting User Access Token" + }); if (!user.access) throw [g_lib.ERR_NOT_FOUND, "No access token found"]; res.send(user.access); - console.info( - "Client:", - user?._id || "unknown", - "|", - "Correlation_ID:", - req.headers["x-correlation-id"], - "|", - "HTTP:", - "GET", - "|", - "Route:", - "/token/get/access", - "|", - "Status:", - "Success", - "|", - "Desc:", - "Getting User Access Token", - ); + logger.logRequestSuccess({ + client: user?._id, + correlationId: req.headers["x-correlation-id"], + httpVerb: "GET", + routePath: basePath + "/token/get/access", + status: "Success", + description: "Getting User Access Token", + extra: user.access + }); } catch (e) { - console.error( - "Client:", - user?._id || "unknown", - "|", - "Correlation_ID:", - req.headers["x-correlation-id"], - "|", - "HTTP:", - "GET", - "|", - "Route:", - "/token/get/access", - "|", - "Status:", - "Failure", - "|", - "Desc:", - "Getting User Access Token", - "|", - "Err:", - e.message || e, - "|", - "Stack:", - e.stack || "No Stack Trace", - ); + logger.logRequestFailure({ + client: user?._id, + correlationId: req.headers["x-correlation-id"], + httpVerb: "GET", + routePath: basePath + "/token/get/access", + status: "Failure", + description: "Getting User Access Token", + extra: user.access, + message: e.message, + stack: e.stack + }); + g_lib.handleException(e, res); } }) @@ -1703,80 +1236,47 @@ router router .get("/token/get/expiring", function (req, res) { let user = undefined; + let result = undefined; try { //console.log("exp:",(Date.now()/1000) + req.queryParams.expires_in); - console.info( - "Client:", - user?._id || "unknown", - "|", - "Correlation_ID:", - req.headers["x-correlation-id"], - "|", - "HTTP:", - "GET", - "|", - "Route:", - "/token/get/expiring", - "|", - "Status:", - "Started", - "|", - "Desc:", - "Getting expiring user access token", - ); + logger.logRequestStarted({ + client: user?._id, + correlationId: req.headers["x-correlation-id"], + httpVerb: "GET", + routePath: basePath + "/token/get/expiring", + status: "Started", + description: "Getting expiring user access token" + }); - var results = g_db._query( + results = g_db._query( "for i in u filter i.expiration != Null && i.expiration < @exp return {id:i._id,access:i.access,refresh:i.refresh,expiration:i.expiration}", { exp: Math.floor(Date.now() / 1000) + req.queryParams.expires_in, }, ); res.send(results); - console.info( - "Client:", - user?._id || "unknown", - "|", - "Correlation_ID:", - req.headers["x-correlation-id"], - "|", - "HTTP:", - "GET", - "|", - "Route:", - "/token/get/expiring", - "|", - "Status:", - "Success", - "|", - "Desc:", - "Getting expiring user access token", - ); + logger.logRequestSuccess({ + client: client?._id, + correlationId: req.headers["x-correlation-id"], + httpVerb: "GET", + routePath: basePath + "/token/get/expiring", + status: "Success", + description: "Getting expiring user access token", + extra: results + }); + } catch (e) { - console.error( - "Client:", - user?._id || "unknown", - "|", - "Correlation_ID:", - req.headers["x-correlation-id"], - "|", - "HTTP:", - "GET", - "|", - "Route:", - "/token/get/expiring", - "|", - "Status:", - "Failure", - "|", - "Desc:", - "Getting expiring user access token", - "|", - "Err:", - e.message || e, - "|", - "Stack:", - e.stack || "No Stack Trace", - ); + logger.logRequestFailure({ + client: client?._id, + correlationId: req.headers["x-correlation-id"], + httpVerb: "GET", + routePath: basePath + "/token/get/expiring", + status: "Failure", + description: "Getting expiring user access token", + extra: result, + message: e.message, + stack: e.stack + }); g_lib.handleException(e, res); } }) @@ -1790,28 +1290,15 @@ router let client = undefined; try { client = g_lib.getUserFromClientID_noexcept(req.queryParams.client); - console.info( - "Client:", - client?._id || "unknown", - "|", - "Correlation_ID:", - req.headers["x-correlation-id"], - "|", - "HTTP:", - "GET", - "|", - "Route:", - "/view", - "|", - "Status:", - "Started", - "|", - "Desc:", - "View User Information", - "|", - "Details:", - req.queryParams.details, - ); + logger.logRequestStarted({ + client: client?._id, + correlationId: req.headers["x-correlation-id"], + httpVerb: "GET", + routePath: basePath + "/view", + status: "Started", + description: "View User Information" + }); + var user, det_ok = false; @@ -1891,58 +1378,28 @@ router delete user.refresh; res.send([user]); - console.info( - "Client:", - client?._id || "unknown", - "|", - "Correlation_ID:", - req.headers["x-correlation-id"], - "|", - "HTTP:", - "GET", - "|", - "Route:", - "/view", - "|", - "Status:", - "Success", - "|", - "Desc:", - "View User Information", - "|", - "Detail:", - req.queryParams.details, - ); + logger.logRequestSuccess({ + client: client?._id, + correlationId: req.headers["x-correlation-id"], + httpVerb: "GET", + routePath: basePath + "/view", + status: "Success", + description: "View User Information", + extra: req.queryParams.details ? client : "undefined" + }); } catch (e) { g_lib.handleException(e, res); - console.error( - "Client:", - client?._id || "unknown", - "|", - "Correlation_ID:", - req.headers["x-correlation-id"], - "|", - "HTTP:", - "GET", - "|", - "Route:", - "/view", - "|", - "Status:", - "Failure", - "|", - "Desc:", - "View User Information", - "|", - "Detail", - req.queryParams.details, - "|", - "Err:", - e.message || e, - "|", - "Stack:", - e.stack || "No Stack Trace", - ); + logger.logRequestFailure({ + client: client?._id, + correlationId: req.headers["x-correlation-id"], + httpVerb: "GET", + routePath: basePath + "/view", + status: "Failure", + description: "View User Information", + extra: req.queryParams.details, + message: e.message, + stack: e.stack + }); } }) .queryParam("client", joi.string().required(), "Client ID") @@ -1956,25 +1413,14 @@ router let client = undefined; var qry = "for i in u sort i.name_last, i.name_first"; var result; - console.info( - "Client:", - client?._id || "unknown", - "|", - "Correlation_ID:", - req.headers["x-correlation-id"], - "|", - "HTTP:", - "GET", - "|", - "Route:", - "/list/all", - "|", - "Status:", - "Started", - "|", - "Desc:", - "List all users", - ); + logger.logRequestStarted({ + client: client?._id, + correlationId: req.headers["x-correlation-id"], + httpVerb: "GET", + routePath: basePath + "/list/all", + status: "Started", + description: "List all users" + }); if (req.queryParams.offset != undefined && req.queryParams.count != undefined) { qry += @@ -2006,26 +1452,16 @@ router } res.send(result); - console.info( - "Client:", - client?._id || "unknown", - "|", - "Correlation_ID:", - req.headers["x-correlation-id"], - "|", - "HTTP:", - "GET", - "|", - "Route:", - "/list/all", - "|", - "Status:", - "Success", - "|", - "Desc:", - "List all users", - ); - }) + logger.logRequestSuccess({ + client: client?._id, + correlationId: req.headers["x-correlation-id"], + httpVerb: "GET", + routePath: basePath + "/list/all", + status: "Started", + description: "List all users", + extra: result, + }); + }) .queryParam("offset", joi.number().optional(), "Offset") .queryParam("count", joi.number().optional(), "Count") .summary("List all users") @@ -2035,25 +1471,14 @@ router .get("/list/collab", function (req, res) { var result, client = g_lib.getUserFromClientID(req.queryParams.client); - console.info( - "Client:", - client?._id || "unknown", - "|", - "Correlation_ID:", - req.headers["x-correlation-id"], - "|", - "HTTP:", - "GET", - "|", - "Route:", - "/list/collab", - "|", - "Status:", - "Started", - "|", - "Desc:", - "List collaborators of client", - ); + logger.logRequestStarted({ + client: client?._id, + correlationId: req.headers["x-correlation-id"], + httpVerb: "GET", + routePath: basePath + "/list/collab", + status: "Started", + description: "List collaborators of client", + }); var qry = "for x in union_distinct((for v in 2..2 any @user owner, member, acl filter is_same_collection('u',v) return" + @@ -2095,25 +1520,15 @@ router } res.send(result); - console.info( - "Client:", - client?._id || "unknown", - "|", - "Correlation_ID:", - req.headers["x-correlation-id"], - "|", - "HTTP:", - "GET", - "|", - "Route:", - "/list/collab", - "|", - "Status:", - "Success", - "|", - "Desc:", - "List collaborators of client", - ); + logger.logRequestSucceed({ + client: client?._id, + correlationId: req.headers["x-correlation-id"], + httpVerb: "GET", + routePath: basePath + "/list/collab", + status: "Started", + description: "List collaborators of client", + extra: result + }); //res.send( g_db._query( "for x in union_distinct((for v in 2..2 any @user owner, member, acl filter is_same_collection('u',v) return distinct { uid: v._id, name: v.name }),(for v in 3..3 inbound @user member, outbound owner, outbound admin filter is_same_collection('u',v) return distinct { uid: v._id, name: v.name }),(for v in 2..2 inbound @user owner, outbound admin filter is_same_collection('u',v) return distinct { uid: v._id, name: v.name })) return x", { user: client._id })); }) @@ -2130,6 +1545,7 @@ Note: must delete ALL data records and projects owned by the user being deleted router .get("/delete", function (req, res) { let client = undefined; + let user_id = undefined; try { g_db._executeTransaction({ collections: { @@ -2156,29 +1572,14 @@ router }, action: function () { client = g_lib.getUserFromClientID(req.queryParams.client); - var user_id; - console.info( - "Client:", - client?._id || "unknown", - "|", - "Correlation_ID:", - req.headers["x-correlation-id"], - "|", - "HTTP:", - "GET", - "|", - "Route:", - "/delete", - "|", - "Status:", - "Started", - "|", - "Desc:", - "Remove existing user entry", - "|", - "Removed user:", - user_id, - ); + logger.logRequestStarted({ + client: client?._id, + correlationId: req.headers["x-correlation-id"], + httpVerb: "GET", + routePath: basePath + "/delete", + status: "Started", + description: "Remove existing user entry" + }); if (req.queryParams.subject) { user_id = req.queryParams.subject; @@ -2245,57 +1646,28 @@ router g_graph.u.remove(user_id); }, }); - console.info( - "Client:", - client?._id || "unknown", - "|", - "Correlation_ID:", - req.headers["x-correlation-id"], - "|", - "HTTP:", - "GET", - "|", - "Route:", - "/delete", - "|", - "Status:", - "Success", - "|", - "Desc:", - "Remove existing user entry", - "|", - "Removed user:", - user_id, - ); + logger.logRequestSuccess({ + client: client?._id, + correlationId: req.headers["x-correlation-id"], + httpVerb: "GET", + routePath: basePath + "/delete", + status: "Success", + description: "Remove existing user entry", + extra: user_id + }); + } catch (e) { - console.error( - "Client:", - client?._id || "unknown", - "|", - "Correlation_ID:", - req.headers["x-correlation-id"], - "|", - "HTTP:", - "GET", - "|", - "Route:", - "/delete", - "|", - "Status:", - "Failure", - "|", - "Desc:", - "Remove existing user entry", - "|", - "Removed user:", - user_id, - "|", - "Err:", - e.message || e, - "|", - "Stack:", - e.stack || "No Stack Trace", - ); + logger.logRequestFailure({ + client: client?._id, + correlationId: req.headers["x-correlation-id"], + httpVerb: "GET", + routePath: basePath + "/delete", + status: "Failure", + description: "Remove existing user entry", + extra: user_id, + message: e.message, + stack: e.stack + }); g_lib.handleException(e, res); } }) @@ -2309,26 +1681,14 @@ router let client = undefined; try { client = g_lib.getUserFromClientID(req.queryParams.client); - console.info( - "Client:", - client?._id || "unknown", - "|", - "Correlation_ID:", - req.headers["x-correlation-id"], - "|", - "HTTP:", - "GET", - "|", - "Route:", - "/ident/list", - "|", - "Status:", - "Started", - "|", - "Desc:", - "List user linked IDs", - ); - + logger.logRequestStarted({ + client: client?._id, + correlationId: req.headers["x-correlation-id"], + httpVerb: "GET", + routePath: basePath + "/ident/list", + status: "Started", + description: "List user linked IDs" + }); if (req.queryParams.subject) { if (!g_db.u.exists(req.queryParams.subject)) throw [ @@ -2343,77 +1703,41 @@ router client: subject._id, }), ); - console.info( - "Client:", - client?._id || "unknown", - "|", - "Correlation_ID:", - req.headers["x-correlation-id"], - "|", - "HTTP:", - "GET", - "|", - "Route:", - "/ident/list", - "|", - "Status:", - "Success", - "|", - "Desc:", - "List user linked IDs", - ); + logger.logRequestSuccess({ + client: client?._id, + correlationId: req.headers["x-correlation-id"], + httpVerb: "GET", + routePath: basePath + "/ident/list", + status: "Success", + description: "List user linked IDs" + }); + } else { res.send( g_db._query("for v in 1..1 outbound @client ident return v._key", { client: client._id, }), ); - console.info( - "Client:", - client?._id || "unknown", - "|", - "Correlation_ID:", - req.headers["x-correlation-id"], - "|", - "HTTP:", - "GET", - "|", - "Route:", - "/ident/list", - "|", - "Status:", - "Success", - "|", - "Desc:", - "List user linked IDs", - ); + logger.logRequestSuccess({ + client: client?._id, + correlationId: req.headers["x-correlation-id"], + httpVerb: "GET", + routePath: basePath + "/ident/list", + status: "Success", + description: "List user linked IDs" + }); } } catch (e) { - console.error( - "Client:", - client?._id || "unknown", - "|", - "Correlation_ID:", - req.headers["x-correlation-id"], - "|", - "HTTP:", - "GET", - "|", - "Route:", - "/ident/list", - "|", - "Status:", - "Failure", - "|", - "Desc:", - "List user linked IDs", - "|", - "Err:", - e.message || e, - "|", - "Stack:", - e.stack || "No Stack Trace", - ); + logger.logRequestFailure({ + client: client?._id, + correlationId: req.headers["x-correlation-id"], + httpVerb: "GET", + routePath: basePath + "/ident/list", + status: "Failure", + description: "List user linked IDs", + message: e.message, + stack: e.stack + }); g_lib.handleException(e, res); } }) @@ -2432,29 +1756,15 @@ router }, action: function () { client = g_lib.getUserFromClientID(req.queryParams.client); - console.info( - "Client:", - client?._id || "unknown", - "|", - "Correlation_ID:", - req.headers["x-correlation-id"], - "|", - "HTTP:", - "GET", - "|", - "Route:", - "/ident/add", - "|", - "Status:", - "Started", - "|", - "Desc:", - "Add new linked identity", - "|", - "Identity:", - req.queryParams.ident, - ); - var id; + var id; + logger.logRequestStarted({ + client: client?._id, + correlationId: req.headers["x-correlation-id"], + httpVerb: "GET", + routePath: basePath + "/ident/add", + status: "Started", + description: "Add new linked identity" + }); if (g_lib.isUUID(req.queryParams.ident)) { if ( @@ -2462,28 +1772,16 @@ router _id: "uuid/" + req.queryParams.ident, }) ) - console.info( - "Client:", - client?._id || "unknown", - "|", - "Correlation_ID:", - req.headers["x-correlation-id"], - "|", - "HTTP:", - "GET", - "|", - "Route:", - "/ident/add", - "|", - "Status:", - "Success", - "|", - "Desc:", - "Add new linked identity", - "|", - "Identity:", - req.queryParams.ident, - ); + logger.logRequestSuccess({ + client: client?._id, + correlationId: req.headers["x-correlation-id"], + httpVerb: "GET", + routePath: basePath + "/ident/add", + status: "Success", + description: "Add new linked identity", + extra: req.queryParams.ident + }); + return; id = g_db.uuid.save( { @@ -2511,29 +1809,16 @@ router }, ); } - console.info( - "Client:", - client?._id || "unknown", - "|", - "Correlation_ID:", - req.headers["x-correlation-id"], - "|", - "HTTP:", - "GET", - "|", - "Route:", - "/ident/add", - "|", - "Status:", - "Success", - "|", - "Desc:", - "Add new linked identity", - "|", - "Identity:", - req.queryParams.ident, - ); - return; + logger.logRequestSuccess({ + client: client?._id, + correlationId: req.headers["x-correlation-id"], + httpVerb: "GET", + routePath: basePath + "/ident/add", + status: "Success", + description: "Add new linked identity", + extra: req.queryParams.ident + }); + return; } else { var accn = { _key: req.queryParams.ident, @@ -2574,57 +1859,29 @@ router } }, }); - console.info( - "Client:", - client?._id || "unknown", - "|", - "Correlation_ID:", - req.headers["x-correlation-id"], - "|", - "HTTP:", - "GET", - "|", - "Route:", - "/ident/add", - "|", - "Status:", - "Success", - "|", - "Desc:", - "Add new linked identity:", - "|", - "Identity:", - req.queryParams.ident, - ); - } catch (e) { - console.error( - "Client:", - client?._id || "unknown", - "|", - "Correlation_ID:", - req.headers["x-correlation-id"], - "|", - "HTTP:", - "GET", - "|", - "Route:", - "/ident/add", - "|", - "Status:", - "Failure", - "|", - "Desc:", - "Add new linked identity", - "|", - "Identity:", - req.queryParams.ident, - "|", - "Err:", - e.message || e, - "|", - "Stack:", - e.stack || "No Stack Trace", - ); + logger.logRequestSuccess({ + client: client?._id, + correlationId: req.headers["x-correlation-id"], + httpVerb: "GET", + routePath: basePath + "/ident/add", + status: "Success", + description: "Add new linked identity", + extra: req.queryParams.ident + }); + + } catch (e) { + + logger.logRequestFailure({ + client: client?._id, + correlationId: req.headers["x-correlation-id"], + httpVerb: "GET", + routePath: basePath + "/ident/add", + status: "Failure", + description: "Add new linked identity", + extra: req.queryParams.ident, + message: e.message, + stack: e.stack + }); g_lib.handleException(e, res); } }) @@ -2650,28 +1907,14 @@ router action: function () { client = g_lib.getUserFromClientID(req.queryParams.client); const owner = g_lib.getUserFromClientID(req.queryParams.ident); - console.info( - "Client:", - client?._id || "unknown", - "|", - "Correlation_ID:", - req.headers["x-correlation-id"], - "|", - "HTTP:", - "GET", - "|", - "Route:", - "/ident/remove", - "|", - "Status:", - "Started", - "|", - "Desc:", - "Remove linked identity from user account", - "|", - "Identity:", - req.queryParams.ident, - ); + logger.logRequestStarted({ + client: client?._id, + correlationId: req.headers["x-correlation-id"], + httpVerb: "GET", + routePath: basePath + "/ident/remove", + status: "Started", + description: "Remove linked identity from user account" + }); g_lib.ensureAdminPermUser(client, owner._id); if (g_lib.isUUID(req.queryParams.ident)) { @@ -2685,57 +1928,27 @@ router ]; }, }); - console.info( - "Client:", - client?._id || "unknown", - "|", - "Correlation_ID:", - req.headers["x-correlation-id"], - "|", - "HTTP:", - "GET", - "|", - "Route:", - "/ident/remove", - "|", - "Status:", - "Success", - "|", - "Desc:", - "Remove linked identity from user account", - "|", - "Identity:", - req.queryParams.ident, - ); + logger.logRequestSuccess({ + client: client?._id, + correlationId: req.headers["x-correlation-id"], + httpVerb: "GET", + routePath: basePath + "/ident/remove", + status: "Success", + description: "Remove linked identity from user account", + extra: req.queryParams.ident + }); } catch (e) { - console.error( - "Client:", - client?._id || "unknown", - "|", - "Correlation_ID:", - req.headers["x-correlation-id"], - "|", - "HTTP:", - "GET", - "|", - "Route:", - "/ident/remove", - "|", - "Status:", - "Failure", - "|", - "Desc:", - "Remove linked identity from user account", - "|", - "Identity:", - req.queryParams.ident, - "|", - "Err:", - e.message || e, - "|", - "Stack:", - e.stack || "No Stack Trace", - ); + logger.logRequestFailure({ + client: client?._id, + correlationId: req.headers["x-correlation-id"], + httpVerb: "GET", + routePath: basePath + "/ident/remove", + status: "Success", + description: "Remove linked identity from user account", + extra: req.queryParams.ident, + message: e.message, + stack: e.stack + }); g_lib.handleException(e, res); } }) @@ -2749,81 +1962,37 @@ router let client = undefined; try { client = g_lib.getUserFromClientID(req.queryParams.client); - console.info( - "Client:", - client?._id || "unknown", - "|", - "Correlation_ID:", - req.headers["x-correlation-id"], - "|", - "HTTP:", - "GET", - "|", - "Route:", - "/ep/get", - "|", - "Status:", - "Started", - "|", - "Desc:", - "Get recent end-points", - "|", - "End-points:", - client.eps, - ); + logger.logRequestStarted({ + client: client?._id, + correlationId: req.headers["x-correlation-id"], + httpVerb: "GET", + routePath: basePath + "/ep/get", + status: "Started", + description: "Get recent end-points" + }); res.send(client.eps ? client.eps : []); - console.info( - "Client:", - client?._id || "unknown", - "|", - "Correlation_ID:", - req.headers["x-correlation-id"], - "|", - "HTTP:", - "GET", - "|", - "Route:", - "/ep/get", - "|", - "Status:", - "Success", - "|", - "Desc:", - "Get recent end-points", - "|", - "End-points:", - client.eps, - ); - } catch (e) { - console.error( - "Client:", - client?._id || "unknown", - "|", - "Correlation_ID:", - req.headers["x-correlation-id"], - "|", - "HTTP:", - "GET", - "|", - "Route:", - "/ep/get", - "|", - "Status:", - "Failure", - "|", - "Desc:", - "Get recent end-points", - "|", - "End-points:", - client.eps, - "|", - "Err:", - e.message || e, - "|", - "Stack:", - e.stack || "No Stack Trace", - ); + logger.logRequestSuccess({ + client: client?._id, + correlationId: req.headers["x-correlation-id"], + httpVerb: "GET", + routePath: basePath + "/ep/get", + status: "Success", + description: "Get recent end-points", + extra: client.eps + }); + } catch (e) { + logger.logRequestFailure({ + client: client?._id, + correlationId: req.headers["x-correlation-id"], + httpVerb: "GET", + routePath: basePath + "/ep/get", + status: "Failure", + description: "Get recent end-points", + extra: client.eps, + message: e.message, + stack: e.stack + }); g_lib.handleException(e, res); } }) @@ -2836,29 +2005,14 @@ router let client = undefined; try { client = g_lib.getUserFromClientID(req.queryParams.client); - console.info( - "Client:", - client?._id || "unknown", - "|", - "Correlation_ID:", - req.headers["x-correlation-id"], - "|", - "HTTP:", - "GET", - "|", - "Route:", - "/ep/set", - "|", - "Status:", - "Started", - "|", - "Desc:", - "Set recent end-points", - "|", - "End-points:", - client.eps, - ); - + logger.logRequestStarted({ + client: client?._id, + correlationId: req.headers["x-correlation-id"], + httpVerb: "GET", + routePath: basePath + "/ep/set", + status: "Started", + description: "Set recent end-points" + }); g_db._update( client._id, { @@ -2868,57 +2022,27 @@ router keepNull: false, }, ); - console.info( - "Client:", - client?._id || "unknown", - "|", - "Correlation_ID:", - req.headers["x-correlation-id"], - "|", - "HTTP:", - "GET", - "|", - "Route:", - "/ep/set", - "|", - "Status:", - "Success", - "|", - "Desc:", - "Set recent end-points", - "|", - "End-points:", - client.eps, - ); + logger.logRequestSuccess({ + client: client?._id, + correlationId: req.headers["x-correlation-id"], + httpVerb: "GET", + routePath: basePath + "/ep/set", + status: "Started", + description: "Set recent end-points", + extra: client.eps + }); } catch (e) { - console.error( - "Client:", - client?._id || "unknown", - "|", - "Correlation_ID:", - req.headers["x-correlation-id"], - "|", - "HTTP:", - "GET", - "|", - "Route:", - "/ep/set", - "|", - "Status:", - "Failure", - "|", - "Desc:", - "Set recent end-points", - "|", - "End-points:", - client.eps, - "|", - "Err:", - e.message || e, - "|", - "Stack:", - e.stack || "No Stack Trace", - ); + logger.logRequestFailure({ + client: client?._id, + correlationId: req.headers["x-correlation-id"], + httpVerb: "GET", + routePath: basePath + "/ep/set", + status: "Started", + description: "Set recent end-points", + extra: client.eps, + message: e.message, + stack: e.stack + }); g_lib.handleException(e, res); } }) From 5a2816989c994d781789fbb8ef94dcf241bee493 Mon Sep 17 00:00:00 2001 From: Austin Hampton Date: Tue, 16 Sep 2025 11:10:39 -0400 Subject: [PATCH 11/36] Forgot to also add the new file --- core/database/foxx/api/lib/logger.js | 83 ++++++++++++++++++++++++++++ 1 file changed, 83 insertions(+) create mode 100644 core/database/foxx/api/lib/logger.js diff --git a/core/database/foxx/api/lib/logger.js b/core/database/foxx/api/lib/logger.js new file mode 100644 index 000000000..228f480d8 --- /dev/null +++ b/core/database/foxx/api/lib/logger.js @@ -0,0 +1,83 @@ +"use strict"; + + +function logRequestSuccess({ + client, + correlationId, + httpVerb, + routePath, + status, + description, + extra +}) { + // helper to pad fields + const pad = (label, value, length = 20) => + `${label}: ${value || "unknown"}`.padEnd(length, " "); + + console.info( + pad("Client", client) + " | " + + pad("Correlation_ID", correlationId) + " | " + + pad("HTTP", httpVerb) + " | " + + pad("Route", routePath) + " | " + + pad("Status", status) + " | " + + pad("Desc", description) + "|" + + pad("Extra", typeof extra === 'object' ? JSON.stringify(extra) : extra) + ); +} + +function logRequestFailure({ + client, + correlationId, + httpVerb, + routePath, + status, + description, + extra, + message, + stack +}) { + // helper to pad fields + const pad = (label, value, length = 20) => + `${label}: ${value || "unknown"}`.padEnd(length, " "); + console.error( + pad("Client:", client) + " | " + + pad("Correlation_ID:", correlationId) + " | " + + pad("HTTP:", httpVerb) + " | " + + pad("Route:", routePath) + " | " + + pad("Status:", status) + " | " + + pad("Desc:", description) + "|" + + pad("Extra", typeof extra === 'object' ? JSON.stringify(extra) : extra) + "|" + + pad("Err:", message) + "|" + + pad("Stack:", stack) + ); +} + + +function logRequestStarted({ + client, + correlationId, + httpVerb, + routePath, + status, + description +}) { + // helper to pad fields + const pad = (label, value, length = 20) => + `${label}: ${value || "unknown"}`.padEnd(length, " "); + + console.info( + pad("Client:", client) + " | " + + pad("Correlation_ID:", correlationId) + " | " + + pad("HTTP:", httpVerb) + " | " + + pad("Route:", routePath) + " | " + + pad("Status:", status) + " | " + + pad("Desc:", description) + ); +} + +// Export the functions +module.exports = { + logRequestSuccess, + logRequestFailure, + logRequestStarted +}; From 0bd70677854a4c955def8ded033c2505a52f561c Mon Sep 17 00:00:00 2001 From: Austin Hampton Date: Tue, 16 Sep 2025 14:51:48 +0000 Subject: [PATCH 12/36] chore: Auto-format JavaScript files with Prettier --- core/database/foxx/api/user_router.js | 810 +++++++++++++------------- 1 file changed, 401 insertions(+), 409 deletions(-) diff --git a/core/database/foxx/api/user_router.js b/core/database/foxx/api/user_router.js index 978fc2154..ea2ac96dc 100644 --- a/core/database/foxx/api/user_router.js +++ b/core/database/foxx/api/user_router.js @@ -10,8 +10,8 @@ const g_graph = require("@arangodb/general-graph")._graph("sdmsg"); const g_lib = require("./support"); const { UserToken } = require("./lib/user_token"); const { UserModel } = require("./models/user"); -const logger = require("./lib/logger") -const basePath = "usr" +const logger = require("./lib/logger"); +const basePath = "usr"; module.exports = router; @@ -187,7 +187,6 @@ router let user = undefined; let result = undefined; try { - g_db._executeTransaction({ collections: { read: ["u"], @@ -246,14 +245,14 @@ router returnNew: true, }); logger.logRequestStarted({ - client: user?._id, - correlationId: req.headers["x-correlation-id"], - httpVerb: "GET", - routePath: basePath + "/create", - status: "Started", - description: "Create new user entry", + client: user?._id, + correlationId: req.headers["x-correlation-id"], + httpVerb: "GET", + routePath: basePath + "/create", + status: "Started", + description: "Create new user entry", }); - + var root = g_db.c.save( { _key: "u_" + req.queryParams.uid + "_root", @@ -336,28 +335,28 @@ router }); res.send(result); logger.logRequestSuccess({ - client: user?._id, - correlationId: req.headers["x-correlation-id"], - httpVerb: "GET", - routePath: basePath + "/create", - status: "Success", - description: "Create new user entry", - extra: result + client: user?._id, + correlationId: req.headers["x-correlation-id"], + httpVerb: "GET", + routePath: basePath + "/create", + status: "Success", + description: "Create new user entry", + extra: result, }); } catch (e) { logger.logRequestFailure({ - client: user?._id, - correlationId: req.headers["x-correlation-id"], - httpVerb: "GET", - routePath: basePath + "/create", - status: "Failure", - description: "Create new user entry", - extra: result, - message: e.message, - stack: e.stack + client: user?._id, + correlationId: req.headers["x-correlation-id"], + httpVerb: "GET", + routePath: basePath + "/create", + status: "Failure", + description: "Create new user entry", + extra: result, + message: e.message, + stack: e.stack, }); g_lib.handleException(e, res); - } + } }) .queryParam( "secret", @@ -380,12 +379,12 @@ router let result = undefined; try { logger.logRequestStarted({ - client: user?._id, - correlationId: req.headers["x-correlation-id"], - httpVerb: "GET", - routePath: basePath + "/create", - status: "Started", - description: "Create new user entry", + client: user?._id, + correlationId: req.headers["x-correlation-id"], + httpVerb: "GET", + routePath: basePath + "/create", + status: "Started", + description: "Create new user entry", }); g_db._executeTransaction({ @@ -397,12 +396,12 @@ router client = g_lib.getUserFromClientID(req.queryParams.client); var user_id; logger.logRequestStarted({ - client: client?._id, - correlationId: req.headers["x-correlation-id"], - httpVerb: "GET", - routePath: basePath + "/update", - status: "Started", - description: "Update user information", + client: client?._id, + correlationId: req.headers["x-correlation-id"], + httpVerb: "GET", + routePath: basePath + "/update", + status: "Started", + description: "Update user information", }); if (req.queryParams.subject) { @@ -465,16 +464,15 @@ router }, }); logger.logRequestSuccess({ - client: client?._id, - correlationId: req.headers["x-correlation-id"], - httpVerb: "GET", - routePath: basePath + "/update", - status: "Success", - description: "Update user information", - extra: result - }); - } catch (e) { - + client: client?._id, + correlationId: req.headers["x-correlation-id"], + httpVerb: "GET", + routePath: basePath + "/update", + status: "Success", + description: "Update user information", + extra: result, + }); + } catch (e) { logger.logRequestFailure({ client: client?._id, correlationId: req.headers["x-correlation-id"], @@ -484,7 +482,7 @@ router description: "Update user information", extra: result, message: e.message, - stack: e.stack + stack: e.stack, }); g_lib.handleException(e, res); } @@ -511,13 +509,13 @@ router user = g_lib.findUserFromUUIDs(uuids); logger.logRequestStarted({ - client: user?._id, - correlationId: req.headers["x-correlation-id"], - httpVerb: "GET", - routePath: basePath + "/find/by_uuids", - status: "Started", - description: "Find a user from list of UUIDs", - }); + client: user?._id, + correlationId: req.headers["x-correlation-id"], + httpVerb: "GET", + routePath: basePath + "/find/by_uuids", + status: "Started", + description: "Find a user from list of UUIDs", + }); var idents = g_db ._query("for v in 1..1 outbound @user ident return v._key", { user: user._id, @@ -536,16 +534,15 @@ router res.send([user]); logger.logRequestSuccess({ - client: user?._id, - correlationId: req.headers["x-correlation-id"], - httpVerb: "GET", - routePath: basePath + "/find/by_uuids", - status: "Started", - description: "Find a user from list of UUIDs", - extra: req.queryParams.uuids - }); - } catch (e) { - + client: user?._id, + correlationId: req.headers["x-correlation-id"], + httpVerb: "GET", + routePath: basePath + "/find/by_uuids", + status: "Started", + description: "Find a user from list of UUIDs", + extra: req.queryParams.uuids, + }); + } catch (e) { logger.logRequestFailure({ client: user?._id, correlationId: req.headers["x-correlation-id"], @@ -555,8 +552,8 @@ router description: "Find a user from list of UUIDs", extra: req.queryParams.uuids, message: e.message, - stack: e.stack - }); + stack: e.stack, + }); g_lib.handleException(e, res); } }) @@ -570,13 +567,13 @@ router try { name = req.queryParams.name_uid.trim(); logger.logRequestStarted({ - client: name, - correlationId: req.headers["x-correlation-id"], - httpVerb: "GET", - routePath: basePath + "/find/by_name_uid", - status: "Started", - description: "Find users matching partial name and/or uid", - }); + client: name, + correlationId: req.headers["x-correlation-id"], + httpVerb: "GET", + routePath: basePath + "/find/by_name_uid", + status: "Started", + description: "Find users matching partial name and/or uid", + }); if (name.length < 2) throw [g_lib.ERR_INVALID_PARAM, "Input is too short for name/uid search."]; @@ -610,26 +607,26 @@ router res.send(result); logger.logRequestSuccess({ - client: name, - correlationId: req.headers["x-correlation-id"], - httpVerb: "GET", - routePath: basePath + "/find/by_name_uid", - status: "Success", - description: "Find users matching partial name and/or uid", - extra: result - }); - } catch (e) { + client: name, + correlationId: req.headers["x-correlation-id"], + httpVerb: "GET", + routePath: basePath + "/find/by_name_uid", + status: "Success", + description: "Find users matching partial name and/or uid", + extra: result, + }); + } catch (e) { logger.logRequestFailure({ - client: name, - correlationId: req.headers["x-correlation-id"], - httpVerb: "GET", - routePath: basePath + "/find/by_name_uid", - status: "Failure", - description: "Find users matching partial name and/or uid", - extra: result, - message: e.message, - stack: e.stack - }); + client: name, + correlationId: req.headers["x-correlation-id"], + httpVerb: "GET", + routePath: basePath + "/find/by_name_uid", + status: "Failure", + description: "Find users matching partial name and/or uid", + extra: result, + message: e.message, + stack: e.stack, + }); g_lib.handleException(e, res); } }) @@ -652,12 +649,12 @@ router client = g_lib.getUserFromClientID(req.queryParams.client); logger.logRequestStarted({ - client: client?._id, - correlationId: req.headers["x-correlation-id"], - httpVerb: "GET", - routePath: basePath + "/keys/set", - status: "Started", - description: "Set user public and private keys", + client: client?._id, + correlationId: req.headers["x-correlation-id"], + httpVerb: "GET", + routePath: basePath + "/keys/set", + status: "Started", + description: "Set user public and private keys", }); var user_id; @@ -682,25 +679,25 @@ router }); logger.logRequestSuccess({ - client: client?._id, - correlationId: req.headers["x-correlation-id"], - httpVerb: "GET", - routePath: basePath + "/keys/set", - status: "Success", - description: "Set user public and private keys", - extra: "undefined", + client: client?._id, + correlationId: req.headers["x-correlation-id"], + httpVerb: "GET", + routePath: basePath + "/keys/set", + status: "Success", + description: "Set user public and private keys", + extra: "undefined", }); - } catch (e) { + } catch (e) { logger.logRequestFailure({ - client: client?._id, - correlationId: req.headers["x-correlation-id"], - httpVerb: "GET", - routePath: basePath + "/keys/set", - status: "Failure", - description: "Set user public and private keys", - extra: "undefined", - message: e.message, - stack: e.stack + client: client?._id, + correlationId: req.headers["x-correlation-id"], + httpVerb: "GET", + routePath: basePath + "/keys/set", + status: "Failure", + description: "Set user public and private keys", + extra: "undefined", + message: e.message, + stack: e.stack, }); g_lib.handleException(e, res); } @@ -722,14 +719,14 @@ router write: ["u"], }, action: function () { - client = g_lib.getUserFromClientID(req.queryParams.client); + client = g_lib.getUserFromClientID(req.queryParams.client); logger.logRequestStarted({ - client: client?._id, - correlationId: req.headers["x-correlation-id"], - httpVerb: "GET", - routePath: basePath + "/keys/clear", - status: "Started", - description: "Clear user public and private keys", + client: client?._id, + correlationId: req.headers["x-correlation-id"], + httpVerb: "GET", + routePath: basePath + "/keys/clear", + status: "Started", + description: "Clear user public and private keys", }); var user_id; @@ -753,26 +750,26 @@ router }, }); logger.logRequestSuccess({ - client: client?._id, - correlationId: req.headers["x-correlation-id"], - httpVerb: "GET", - routePath: basePath + "/keys/clear", - status: "Success", - description: "Clear user public and private keys", - extra: "undefined", - }); + client: client?._id, + correlationId: req.headers["x-correlation-id"], + httpVerb: "GET", + routePath: basePath + "/keys/clear", + status: "Success", + description: "Clear user public and private keys", + extra: "undefined", + }); } catch (e) { logger.logRequestFailure({ - client: client?._id, - correlationId: req.headers["x-correlation-id"], - httpVerb: "GET", - routePath: basePath + "/keys/clear", - status: "Failure", - description: "Clear user public and private keys", - extra: "undefined", - message: e.message, - stack: e.stack - }); + client: client?._id, + correlationId: req.headers["x-correlation-id"], + httpVerb: "GET", + routePath: basePath + "/keys/clear", + status: "Failure", + description: "Clear user public and private keys", + extra: "undefined", + message: e.message, + stack: e.stack, + }); g_lib.handleException(e, res); } }) @@ -802,7 +799,7 @@ router routePath: basePath + "/keys/get", status: "Started", description: "Get user public and private keys", - }); + }); } else { user = g_lib.getUserFromClientID(req.queryParams.client); } @@ -813,7 +810,7 @@ router uid: user._id, }, ]); - logger.logRequestSuccess({ + logger.logRequestSuccess({ client: user?._id, correlationId: req.headers["x-correlation-id"], httpVerb: "GET", @@ -821,7 +818,7 @@ router status: "Success", description: "Get user public and private keys", extra: "undefined", - }); + }); } else res.send([ { @@ -831,25 +828,25 @@ router }, ]); logger.logRequestSuccess({ - client: user?._id, - correlationId: req.headers["x-correlation-id"], - httpVerb: "GET", - routePath: basePath + "/keys/get", - status: "Success", - description: "Get user public and private keys", - extra: "undefined", - }); - } catch (e) { + client: user?._id, + correlationId: req.headers["x-correlation-id"], + httpVerb: "GET", + routePath: basePath + "/keys/get", + status: "Success", + description: "Get user public and private keys", + extra: "undefined", + }); + } catch (e) { logger.logRequestFailure({ - client: user?._id, - correlationId: req.headers["x-correlation-id"], - httpVerb: "GET", - routePath: basePath + "/keys/get", - status: "Failure", - description: "Get user public and private keys", - extra: "undefined", - message: e.message, - stack: e.stack + client: user?._id, + correlationId: req.headers["x-correlation-id"], + httpVerb: "GET", + routePath: basePath + "/keys/get", + status: "Failure", + description: "Get user public and private keys", + extra: "undefined", + message: e.message, + stack: e.stack, }); g_lib.handleException(e, res); } @@ -865,34 +862,34 @@ router try { uid = g_lib.uidFromPubKey(req.queryParams.pub_key); logger.logRequestStarted({ - client: uid, - correlationId: req.headers["x-correlation-id"], - httpVerb: "GET", - routePath: basePath + "/find/by_pub_key", - status: "Started", - description: "Find a user by public key" - }); + client: uid, + correlationId: req.headers["x-correlation-id"], + httpVerb: "GET", + routePath: basePath + "/find/by_pub_key", + status: "Started", + description: "Find a user by public key", + }); res.send(uid); logger.logRequestSuccess({ - client: uid, - correlationId: req.headers["x-correlation-id"], - httpVerb: "GET", - routePath: basePath + "/find/by_pub_key", - status: "Success", - description: "Find a user by public key", - extra: uid, - }); - } catch (e) { + client: uid, + correlationId: req.headers["x-correlation-id"], + httpVerb: "GET", + routePath: basePath + "/find/by_pub_key", + status: "Success", + description: "Find a user by public key", + extra: uid, + }); + } catch (e) { logger.logRequestFailure({ - client: uid, - correlationId: req.headers["x-correlation-id"], - httpVerb: "GET", - routePath: basePath + "/find/by_pub_key", - status: "Failure", - description: "Find a user by public key", - extra: uid, - message: e.message, - stack: e.stack + client: uid, + correlationId: req.headers["x-correlation-id"], + httpVerb: "GET", + routePath: basePath + "/find/by_pub_key", + status: "Failure", + description: "Find a user by public key", + extra: uid, + message: e.message, + stack: e.stack, }); g_lib.handleException(e, res); } @@ -912,14 +909,14 @@ router }, action: function () { client = g_lib.getUserFromClientID(req.queryParams.client); - + logger.logRequestStarted({ - client: client?._id, - correlationId: req.headers["x-correlation-id"], - httpVerb: "GET", - routePath: basePath + "/token/set", - status: "Started", - description: "Setting user token" + client: client?._id, + correlationId: req.headers["x-correlation-id"], + httpVerb: "GET", + routePath: basePath + "/token/set", + status: "Started", + description: "Setting user token", }); var user_id; @@ -1043,22 +1040,22 @@ router routePath: basePath + "/token/set", status: "Success", description: "Setting user token", - extra: "undefined" + extra: "undefined", }); } }, }); } catch (e) { logger.logRequestFailure({ - client: client?._id, - correlationId: req.headers["x-correlation-id"], - httpVerb: "GET", - routePath: basePath + "/token/set", - status: "Failure", - description: "Setting user tokens", - extra: "undefined", - message: e.message, - stack: e.stack + client: client?._id, + correlationId: req.headers["x-correlation-id"], + httpVerb: "GET", + routePath: basePath + "/token/set", + status: "Failure", + description: "Setting user tokens", + extra: "undefined", + message: e.message, + stack: e.stack, }); g_lib.handleException(e, res); } @@ -1112,13 +1109,13 @@ router } logger.logRequestStarted({ - client: user?._id, - correlationId: req.headers["x-correlation-id"], - httpVerb: "GET", - routePath: basePath + "/token/get", - status: "Started", - description: "Getting user token" - }); + client: user?._id, + correlationId: req.headers["x-correlation-id"], + httpVerb: "GET", + routePath: basePath + "/token/get", + status: "Started", + description: "Getting user token", + }); const user_token = new UserToken({ user_id: user._id, @@ -1138,24 +1135,24 @@ router res.send(result); logger.logRequestSuccess({ - client: user?._id, - correlationId: req.headers["x-correlation-id"], - httpVerb: "GET", - routePath: basePath + "/token/get", - status: "Success", - description: "Getting user token" - }); + client: user?._id, + correlationId: req.headers["x-correlation-id"], + httpVerb: "GET", + routePath: basePath + "/token/get", + status: "Success", + description: "Getting user token", + }); } catch (e) { logger.logRequestFailure({ - client: user?._id, - correlationId: req.headers["x-correlation-id"], - httpVerb: "GET", - routePath: basePath + "/token/get", - status: "Failure", - description: "Getting user tokens", - extra: "undefined", - message: e.message, - stack: e.stack + client: user?._id, + correlationId: req.headers["x-correlation-id"], + httpVerb: "GET", + routePath: basePath + "/token/get", + status: "Failure", + description: "Getting user tokens", + extra: "undefined", + message: e.message, + stack: e.stack, }); g_lib.handleException(e, res); } @@ -1192,38 +1189,38 @@ router user = g_lib.getUserFromClientID(req.queryParams.client); } logger.logRequestStarted({ - client: user?._id, - correlationId: req.headers["x-correlation-id"], - httpVerb: "GET", - routePath: basePath + "/token/get/access", - status: "Started", - description: "Getting User Access Token" - }); + client: user?._id, + correlationId: req.headers["x-correlation-id"], + httpVerb: "GET", + routePath: basePath + "/token/get/access", + status: "Started", + description: "Getting User Access Token", + }); if (!user.access) throw [g_lib.ERR_NOT_FOUND, "No access token found"]; res.send(user.access); logger.logRequestSuccess({ - client: user?._id, - correlationId: req.headers["x-correlation-id"], - httpVerb: "GET", - routePath: basePath + "/token/get/access", - status: "Success", - description: "Getting User Access Token", - extra: user.access - }); + client: user?._id, + correlationId: req.headers["x-correlation-id"], + httpVerb: "GET", + routePath: basePath + "/token/get/access", + status: "Success", + description: "Getting User Access Token", + extra: user.access, + }); } catch (e) { logger.logRequestFailure({ - client: user?._id, - correlationId: req.headers["x-correlation-id"], - httpVerb: "GET", - routePath: basePath + "/token/get/access", - status: "Failure", - description: "Getting User Access Token", - extra: user.access, - message: e.message, - stack: e.stack - }); + client: user?._id, + correlationId: req.headers["x-correlation-id"], + httpVerb: "GET", + routePath: basePath + "/token/get/access", + status: "Failure", + description: "Getting User Access Token", + extra: user.access, + message: e.message, + stack: e.stack, + }); g_lib.handleException(e, res); } @@ -1245,8 +1242,8 @@ router httpVerb: "GET", routePath: basePath + "/token/get/expiring", status: "Started", - description: "Getting expiring user access token" - }); + description: "Getting expiring user access token", + }); results = g_db._query( "for i in u filter i.expiration != Null && i.expiration < @exp return {id:i._id,access:i.access,refresh:i.refresh,expiration:i.expiration}", @@ -1262,21 +1259,20 @@ router routePath: basePath + "/token/get/expiring", status: "Success", description: "Getting expiring user access token", - extra: results - }); - + extra: results, + }); } catch (e) { logger.logRequestFailure({ - client: client?._id, - correlationId: req.headers["x-correlation-id"], - httpVerb: "GET", - routePath: basePath + "/token/get/expiring", - status: "Failure", - description: "Getting expiring user access token", - extra: result, - message: e.message, - stack: e.stack - }); + client: client?._id, + correlationId: req.headers["x-correlation-id"], + httpVerb: "GET", + routePath: basePath + "/token/get/expiring", + status: "Failure", + description: "Getting expiring user access token", + extra: result, + message: e.message, + stack: e.stack, + }); g_lib.handleException(e, res); } }) @@ -1296,8 +1292,8 @@ router httpVerb: "GET", routePath: basePath + "/view", status: "Started", - description: "View User Information" - }); + description: "View User Information", + }); var user, det_ok = false; @@ -1385,7 +1381,7 @@ router routePath: basePath + "/view", status: "Success", description: "View User Information", - extra: req.queryParams.details ? client : "undefined" + extra: req.queryParams.details ? client : "undefined", }); } catch (e) { g_lib.handleException(e, res); @@ -1398,7 +1394,7 @@ router description: "View User Information", extra: req.queryParams.details, message: e.message, - stack: e.stack + stack: e.stack, }); } }) @@ -1414,13 +1410,13 @@ router var qry = "for i in u sort i.name_last, i.name_first"; var result; logger.logRequestStarted({ - client: client?._id, - correlationId: req.headers["x-correlation-id"], - httpVerb: "GET", - routePath: basePath + "/list/all", - status: "Started", - description: "List all users" - }); + client: client?._id, + correlationId: req.headers["x-correlation-id"], + httpVerb: "GET", + routePath: basePath + "/list/all", + status: "Started", + description: "List all users", + }); if (req.queryParams.offset != undefined && req.queryParams.count != undefined) { qry += @@ -1453,15 +1449,15 @@ router res.send(result); logger.logRequestSuccess({ - client: client?._id, - correlationId: req.headers["x-correlation-id"], - httpVerb: "GET", - routePath: basePath + "/list/all", - status: "Started", - description: "List all users", - extra: result, - }); - }) + client: client?._id, + correlationId: req.headers["x-correlation-id"], + httpVerb: "GET", + routePath: basePath + "/list/all", + status: "Started", + description: "List all users", + extra: result, + }); + }) .queryParam("offset", joi.number().optional(), "Offset") .queryParam("count", joi.number().optional(), "Count") .summary("List all users") @@ -1471,14 +1467,14 @@ router .get("/list/collab", function (req, res) { var result, client = g_lib.getUserFromClientID(req.queryParams.client); - logger.logRequestStarted({ - client: client?._id, - correlationId: req.headers["x-correlation-id"], - httpVerb: "GET", - routePath: basePath + "/list/collab", - status: "Started", - description: "List collaborators of client", - }); + logger.logRequestStarted({ + client: client?._id, + correlationId: req.headers["x-correlation-id"], + httpVerb: "GET", + routePath: basePath + "/list/collab", + status: "Started", + description: "List collaborators of client", + }); var qry = "for x in union_distinct((for v in 2..2 any @user owner, member, acl filter is_same_collection('u',v) return" + @@ -1521,14 +1517,14 @@ router res.send(result); logger.logRequestSucceed({ - client: client?._id, - correlationId: req.headers["x-correlation-id"], - httpVerb: "GET", - routePath: basePath + "/list/collab", - status: "Started", - description: "List collaborators of client", - extra: result - }); + client: client?._id, + correlationId: req.headers["x-correlation-id"], + httpVerb: "GET", + routePath: basePath + "/list/collab", + status: "Started", + description: "List collaborators of client", + extra: result, + }); //res.send( g_db._query( "for x in union_distinct((for v in 2..2 any @user owner, member, acl filter is_same_collection('u',v) return distinct { uid: v._id, name: v.name }),(for v in 3..3 inbound @user member, outbound owner, outbound admin filter is_same_collection('u',v) return distinct { uid: v._id, name: v.name }),(for v in 2..2 inbound @user owner, outbound admin filter is_same_collection('u',v) return distinct { uid: v._id, name: v.name })) return x", { user: client._id })); }) @@ -1572,14 +1568,14 @@ router }, action: function () { client = g_lib.getUserFromClientID(req.queryParams.client); - logger.logRequestStarted({ - client: client?._id, - correlationId: req.headers["x-correlation-id"], - httpVerb: "GET", - routePath: basePath + "/delete", - status: "Started", - description: "Remove existing user entry" - }); + logger.logRequestStarted({ + client: client?._id, + correlationId: req.headers["x-correlation-id"], + httpVerb: "GET", + routePath: basePath + "/delete", + status: "Started", + description: "Remove existing user entry", + }); if (req.queryParams.subject) { user_id = req.queryParams.subject; @@ -1653,9 +1649,8 @@ router routePath: basePath + "/delete", status: "Success", description: "Remove existing user entry", - extra: user_id - }); - + extra: user_id, + }); } catch (e) { logger.logRequestFailure({ client: client?._id, @@ -1666,8 +1661,8 @@ router description: "Remove existing user entry", extra: user_id, message: e.message, - stack: e.stack - }); + stack: e.stack, + }); g_lib.handleException(e, res); } }) @@ -1682,13 +1677,13 @@ router try { client = g_lib.getUserFromClientID(req.queryParams.client); logger.logRequestStarted({ - client: client?._id, - correlationId: req.headers["x-correlation-id"], - httpVerb: "GET", - routePath: basePath + "/ident/list", - status: "Started", - description: "List user linked IDs" - }); + client: client?._id, + correlationId: req.headers["x-correlation-id"], + httpVerb: "GET", + routePath: basePath + "/ident/list", + status: "Started", + description: "List user linked IDs", + }); if (req.queryParams.subject) { if (!g_db.u.exists(req.queryParams.subject)) throw [ @@ -1709,9 +1704,8 @@ router httpVerb: "GET", routePath: basePath + "/ident/list", status: "Success", - description: "List user linked IDs" + description: "List user linked IDs", }); - } else { res.send( g_db._query("for v in 1..1 outbound @client ident return v._key", { @@ -1724,20 +1718,20 @@ router httpVerb: "GET", routePath: basePath + "/ident/list", status: "Success", - description: "List user linked IDs" + description: "List user linked IDs", }); } } catch (e) { logger.logRequestFailure({ - client: client?._id, - correlationId: req.headers["x-correlation-id"], - httpVerb: "GET", - routePath: basePath + "/ident/list", - status: "Failure", - description: "List user linked IDs", - message: e.message, - stack: e.stack - }); + client: client?._id, + correlationId: req.headers["x-correlation-id"], + httpVerb: "GET", + routePath: basePath + "/ident/list", + status: "Failure", + description: "List user linked IDs", + message: e.message, + stack: e.stack, + }); g_lib.handleException(e, res); } }) @@ -1756,14 +1750,14 @@ router }, action: function () { client = g_lib.getUserFromClientID(req.queryParams.client); - var id; + var id; logger.logRequestStarted({ client: client?._id, correlationId: req.headers["x-correlation-id"], httpVerb: "GET", routePath: basePath + "/ident/add", status: "Started", - description: "Add new linked identity" + description: "Add new linked identity", }); if (g_lib.isUUID(req.queryParams.ident)) { @@ -1772,16 +1766,16 @@ router _id: "uuid/" + req.queryParams.ident, }) ) - logger.logRequestSuccess({ - client: client?._id, - correlationId: req.headers["x-correlation-id"], - httpVerb: "GET", - routePath: basePath + "/ident/add", - status: "Success", - description: "Add new linked identity", - extra: req.queryParams.ident - }); - + logger.logRequestSuccess({ + client: client?._id, + correlationId: req.headers["x-correlation-id"], + httpVerb: "GET", + routePath: basePath + "/ident/add", + status: "Success", + description: "Add new linked identity", + extra: req.queryParams.ident, + }); + return; id = g_db.uuid.save( { @@ -1809,16 +1803,16 @@ router }, ); } - logger.logRequestSuccess({ - client: client?._id, - correlationId: req.headers["x-correlation-id"], - httpVerb: "GET", - routePath: basePath + "/ident/add", - status: "Success", - description: "Add new linked identity", - extra: req.queryParams.ident - }); - return; + logger.logRequestSuccess({ + client: client?._id, + correlationId: req.headers["x-correlation-id"], + httpVerb: "GET", + routePath: basePath + "/ident/add", + status: "Success", + description: "Add new linked identity", + extra: req.queryParams.ident, + }); + return; } else { var accn = { _key: req.queryParams.ident, @@ -1866,11 +1860,9 @@ router routePath: basePath + "/ident/add", status: "Success", description: "Add new linked identity", - extra: req.queryParams.ident + extra: req.queryParams.ident, }); - - } catch (e) { - + } catch (e) { logger.logRequestFailure({ client: client?._id, correlationId: req.headers["x-correlation-id"], @@ -1880,7 +1872,7 @@ router description: "Add new linked identity", extra: req.queryParams.ident, message: e.message, - stack: e.stack + stack: e.stack, }); g_lib.handleException(e, res); } @@ -1913,7 +1905,7 @@ router httpVerb: "GET", routePath: basePath + "/ident/remove", status: "Started", - description: "Remove linked identity from user account" + description: "Remove linked identity from user account", }); g_lib.ensureAdminPermUser(client, owner._id); @@ -1935,7 +1927,7 @@ router routePath: basePath + "/ident/remove", status: "Success", description: "Remove linked identity from user account", - extra: req.queryParams.ident + extra: req.queryParams.ident, }); } catch (e) { logger.logRequestFailure({ @@ -1947,7 +1939,7 @@ router description: "Remove linked identity from user account", extra: req.queryParams.ident, message: e.message, - stack: e.stack + stack: e.stack, }); g_lib.handleException(e, res); } @@ -1963,36 +1955,36 @@ router try { client = g_lib.getUserFromClientID(req.queryParams.client); logger.logRequestStarted({ - client: client?._id, - correlationId: req.headers["x-correlation-id"], - httpVerb: "GET", - routePath: basePath + "/ep/get", - status: "Started", - description: "Get recent end-points" - }); + client: client?._id, + correlationId: req.headers["x-correlation-id"], + httpVerb: "GET", + routePath: basePath + "/ep/get", + status: "Started", + description: "Get recent end-points", + }); res.send(client.eps ? client.eps : []); logger.logRequestSuccess({ - client: client?._id, - correlationId: req.headers["x-correlation-id"], - httpVerb: "GET", - routePath: basePath + "/ep/get", - status: "Success", - description: "Get recent end-points", - extra: client.eps - }); - } catch (e) { + client: client?._id, + correlationId: req.headers["x-correlation-id"], + httpVerb: "GET", + routePath: basePath + "/ep/get", + status: "Success", + description: "Get recent end-points", + extra: client.eps, + }); + } catch (e) { logger.logRequestFailure({ - client: client?._id, - correlationId: req.headers["x-correlation-id"], - httpVerb: "GET", - routePath: basePath + "/ep/get", - status: "Failure", - description: "Get recent end-points", - extra: client.eps, - message: e.message, - stack: e.stack - }); + client: client?._id, + correlationId: req.headers["x-correlation-id"], + httpVerb: "GET", + routePath: basePath + "/ep/get", + status: "Failure", + description: "Get recent end-points", + extra: client.eps, + message: e.message, + stack: e.stack, + }); g_lib.handleException(e, res); } }) @@ -2006,13 +1998,13 @@ router try { client = g_lib.getUserFromClientID(req.queryParams.client); logger.logRequestStarted({ - client: client?._id, - correlationId: req.headers["x-correlation-id"], - httpVerb: "GET", - routePath: basePath + "/ep/set", - status: "Started", - description: "Set recent end-points" - }); + client: client?._id, + correlationId: req.headers["x-correlation-id"], + httpVerb: "GET", + routePath: basePath + "/ep/set", + status: "Started", + description: "Set recent end-points", + }); g_db._update( client._id, { @@ -2023,14 +2015,14 @@ router }, ); logger.logRequestSuccess({ - client: client?._id, - correlationId: req.headers["x-correlation-id"], - httpVerb: "GET", - routePath: basePath + "/ep/set", - status: "Started", - description: "Set recent end-points", - extra: client.eps - }); + client: client?._id, + correlationId: req.headers["x-correlation-id"], + httpVerb: "GET", + routePath: basePath + "/ep/set", + status: "Started", + description: "Set recent end-points", + extra: client.eps, + }); } catch (e) { logger.logRequestFailure({ client: client?._id, @@ -2041,7 +2033,7 @@ router description: "Set recent end-points", extra: client.eps, message: e.message, - stack: e.stack + stack: e.stack, }); g_lib.handleException(e, res); } From b86bc22947d722df3cd5f977ddae2d5fdd8b7147 Mon Sep 17 00:00:00 2001 From: Austin Hampton Date: Tue, 16 Sep 2025 15:55:26 +0000 Subject: [PATCH 13/36] chore: Auto-format JavaScript files with Prettier --- core/database/foxx/api/lib/logger.js | 144 ++++++++++++++------------- 1 file changed, 77 insertions(+), 67 deletions(-) diff --git a/core/database/foxx/api/lib/logger.js b/core/database/foxx/api/lib/logger.js index 228f480d8..a39516fba 100644 --- a/core/database/foxx/api/lib/logger.js +++ b/core/database/foxx/api/lib/logger.js @@ -1,83 +1,93 @@ "use strict"; - function logRequestSuccess({ - client, - correlationId, - httpVerb, - routePath, - status, - description, - extra + client, + correlationId, + httpVerb, + routePath, + status, + description, + extra, }) { - // helper to pad fields - const pad = (label, value, length = 20) => - `${label}: ${value || "unknown"}`.padEnd(length, " "); - - console.info( - pad("Client", client) + " | " + - pad("Correlation_ID", correlationId) + " | " + - pad("HTTP", httpVerb) + " | " + - pad("Route", routePath) + " | " + - pad("Status", status) + " | " + - pad("Desc", description) + "|" + - pad("Extra", typeof extra === 'object' ? JSON.stringify(extra) : extra) - ); + // helper to pad fields + const pad = (label, value, length = 20) => + `${label}: ${value || "unknown"}`.padEnd(length, " "); + + console.info( + pad("Client", client) + + " | " + + pad("Correlation_ID", correlationId) + + " | " + + pad("HTTP", httpVerb) + + " | " + + pad("Route", routePath) + + " | " + + pad("Status", status) + + " | " + + pad("Desc", description) + + "|" + + pad("Extra", typeof extra === "object" ? JSON.stringify(extra) : extra), + ); } function logRequestFailure({ - client, - correlationId, - httpVerb, - routePath, - status, - description, - extra, - message, - stack + client, + correlationId, + httpVerb, + routePath, + status, + description, + extra, + message, + stack, }) { - // helper to pad fields - const pad = (label, value, length = 20) => - `${label}: ${value || "unknown"}`.padEnd(length, " "); - console.error( - pad("Client:", client) + " | " + - pad("Correlation_ID:", correlationId) + " | " + - pad("HTTP:", httpVerb) + " | " + - pad("Route:", routePath) + " | " + - pad("Status:", status) + " | " + - pad("Desc:", description) + "|" + - pad("Extra", typeof extra === 'object' ? JSON.stringify(extra) : extra) + "|" + - pad("Err:", message) + "|" + - pad("Stack:", stack) - ); + // helper to pad fields + const pad = (label, value, length = 20) => + `${label}: ${value || "unknown"}`.padEnd(length, " "); + console.error( + pad("Client:", client) + + " | " + + pad("Correlation_ID:", correlationId) + + " | " + + pad("HTTP:", httpVerb) + + " | " + + pad("Route:", routePath) + + " | " + + pad("Status:", status) + + " | " + + pad("Desc:", description) + + "|" + + pad("Extra", typeof extra === "object" ? JSON.stringify(extra) : extra) + + "|" + + pad("Err:", message) + + "|" + + pad("Stack:", stack), + ); } +function logRequestStarted({ client, correlationId, httpVerb, routePath, status, description }) { + // helper to pad fields + const pad = (label, value, length = 20) => + `${label}: ${value || "unknown"}`.padEnd(length, " "); -function logRequestStarted({ - client, - correlationId, - httpVerb, - routePath, - status, - description -}) { - // helper to pad fields - const pad = (label, value, length = 20) => - `${label}: ${value || "unknown"}`.padEnd(length, " "); - - console.info( - pad("Client:", client) + " | " + - pad("Correlation_ID:", correlationId) + " | " + - pad("HTTP:", httpVerb) + " | " + - pad("Route:", routePath) + " | " + - pad("Status:", status) + " | " + - pad("Desc:", description) - ); + console.info( + pad("Client:", client) + + " | " + + pad("Correlation_ID:", correlationId) + + " | " + + pad("HTTP:", httpVerb) + + " | " + + pad("Route:", routePath) + + " | " + + pad("Status:", status) + + " | " + + pad("Desc:", description), + ); } // Export the functions module.exports = { - logRequestSuccess, - logRequestFailure, - logRequestStarted + logRequestSuccess, + logRequestFailure, + logRequestStarted, }; From 89b1ae50a5f0ddd1ccdfff2ed31727a4ebb1b52e Mon Sep 17 00:00:00 2001 From: Austin Hampton Date: Wed, 17 Sep 2025 14:35:33 -0400 Subject: [PATCH 14/36] refactor:Made final adjustments to logging within user router --- core/database/foxx/api/lib/logger.js | 28 ++-- core/database/foxx/api/user_router.js | 176 +++++++++----------------- 2 files changed, 74 insertions(+), 130 deletions(-) diff --git a/core/database/foxx/api/lib/logger.js b/core/database/foxx/api/lib/logger.js index a39516fba..368c5b8f5 100644 --- a/core/database/foxx/api/lib/logger.js +++ b/core/database/foxx/api/lib/logger.js @@ -45,23 +45,23 @@ function logRequestFailure({ const pad = (label, value, length = 20) => `${label}: ${value || "unknown"}`.padEnd(length, " "); console.error( - pad("Client:", client) + + pad("Client", client) + " | " + - pad("Correlation_ID:", correlationId) + + pad("Correlation_ID", correlationId) + " | " + - pad("HTTP:", httpVerb) + + pad("HTTP", httpVerb) + " | " + - pad("Route:", routePath) + + pad("Route", routePath) + " | " + - pad("Status:", status) + + pad("Status", status) + " | " + - pad("Desc:", description) + + pad("Desc", description) + "|" + pad("Extra", typeof extra === "object" ? JSON.stringify(extra) : extra) + "|" + - pad("Err:", message) + + pad("Err", message) + "|" + - pad("Stack:", stack), + pad("Stack", stack), ); } @@ -71,17 +71,17 @@ function logRequestStarted({ client, correlationId, httpVerb, routePath, status, `${label}: ${value || "unknown"}`.padEnd(length, " "); console.info( - pad("Client:", client) + + pad("Client", client) + " | " + - pad("Correlation_ID:", correlationId) + + pad("Correlation_ID", correlationId) + " | " + - pad("HTTP:", httpVerb) + + pad("HTTP", httpVerb) + " | " + - pad("Route:", routePath) + + pad("Route", routePath) + " | " + - pad("Status:", status) + + pad("Status", status) + " | " + - pad("Desc:", description), + pad("Desc", description), ); } diff --git a/core/database/foxx/api/user_router.js b/core/database/foxx/api/user_router.js index ea2ac96dc..636c92aad 100644 --- a/core/database/foxx/api/user_router.js +++ b/core/database/foxx/api/user_router.js @@ -27,20 +27,14 @@ router if (is_verified === false) { throw g_lib.ERR_AUTHN_FAILED; } - console.info( - "Client:", - client?._id || "unknown", - "Correlation_ID:", - req.headers["x-correlation-id"], - "HTTP:", - "GET", - "Route:", - "/authn/password", - "Status:", - "Started", - "Desc:", - "Authenticating user via password", - ); + logger.logRequestStarted({ + client: client?._id, + correlationId: req.headers["x-correlation-id"], + httpVerb: "GET", + routePath: basePath + "/authn/password", + status: "Started", + description: "Authenticating user via password", + }); //if ( client.password != req.queryParams.pw ) // throw g_lib.ERR_AUTHN_FAILED; @@ -49,46 +43,28 @@ router uid: client._id, authorized: true, }); - console.info( - "Client:", - client?._id || "unknown", - "Correlation_ID:", - req.headers["x-correlation-id"], - "HTTP:", - "GET", - "Route:", - "/authn/password", - "Status:", - "Success", - "Desc:", - "Authenticating user via password", - ); + logger.logRequestSuccess({ + client: client?._id, + correlationId: req.headers["x-correlation-id"], + httpVerb: "GET", + routePath: basePath + "/authn/password", + status: "Success", + description: "Authenticating user via password", + extra: "undefined" + }); + } catch (e) { - console.info( - "Client:", - client?._id || "unknown", - "|", - "Correlation_ID:", - req.headers["x-correlation-id"], - "|", - "HTTP:", - "GET", - "|", - "Route:", - "/authn/password", - "|", - "Status:", - "Failure", - "|", - "Desc:", - "Authenticating user via password", - "|", - "Err:", - e.message || e, - "|", - "Stack:", - e.stack || "No Stack Trace", - ); + logger.logRequestFailure({ + client: client?._id, + correlationId: req.headers["x-correlation-id"], + httpVerb: "GET", + routePath: basePath + "/authn/password", + status: "Success", + description: "Authenticating user via password", + extra: "undefined", + message: e.message, + stack: e.stack + }); g_lib.handleException(e, res); } }) @@ -104,25 +80,14 @@ router user = g_db._query("for i in u filter i.access == @tok return i", { tok: req.queryParams.token, }); - console.info( - "Client:", - user?._id || "unknown", - "|", - "Correlation_ID:", - req.headers["x-correlation-id"], - "|", - "HTTP:", - "GET", - "|", - "Route:", - "/authn/token", - "|", - "Status:", - "Started", - "|", - "Desc:", - "Authenticating user via access token", - ); + logger.logRequestStarted({ + client: user?._id, + correlationId: req.headers["x-correlation-id"], + httpVerb: "GET", + routePath: basePath + "/authn/token", + status: "Started", + description: "Authenticating user via access token", + }); if (!user.hasNext()) throw g_lib.ERR_AUTHN_FAILED; @@ -130,51 +95,30 @@ router uid: user.next()._id, authorized: true, }); - console.info( - "Client:", - user?._id || "unknown", - "|", - "Correlation_ID:", - req.headers["x-correlation-id"], - "|", - "HTTP:", - "GET", - "|", - "Route:", - "/authn/token", - "|", - "Status:", - "Success", - "|", - "Desc:", - "Authenticating user via access token", - ); + + logger.logRequestSuccess({ + client: user?._id, + correlationId: req.headers["x-correlation-id"], + httpVerb: "GET", + routePath: basePath + "/authn/token", + status: "Success", + description: "Authenticating user via access token", + extra: "undefined" + }); + } catch (e) { - console.info( - "Client:", - user?._id || "unknown", - "|", - "Correlation_ID:", - req.headers["x-correlation-id"], - "|", - "HTTP:", - "GET", - "|", - "Route:", - "/authn/token", - "|", - "Status:", - "Failure", - "|", - "Desc:", - "Authenticating user via access token", - "|", - "Err:", - e.message || e, - "|", - "Stack:", - e.stack || "No Stack Trace", - ); + logger.logRequestFailure({ + client: user?._id, + correlationId: req.headers["x-correlation-id"], + httpVerb: "GET", + routePath: basePath + "/authn/token", + status: "Failure", + description: "Authenticating user via access token", + extra: "undefined", + message: e.message, + stack: e.stack + }); + g_lib.handleException(e, res); } }) From 4f14fcf932a96ee2b157de84654a7ad70b127ae2 Mon Sep 17 00:00:00 2001 From: Austin Hampton Date: Wed, 17 Sep 2025 18:36:23 +0000 Subject: [PATCH 15/36] chore: Auto-format JavaScript files with Prettier --- core/database/foxx/api/user_router.js | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/core/database/foxx/api/user_router.js b/core/database/foxx/api/user_router.js index 636c92aad..f8a4ec81e 100644 --- a/core/database/foxx/api/user_router.js +++ b/core/database/foxx/api/user_router.js @@ -50,9 +50,8 @@ router routePath: basePath + "/authn/password", status: "Success", description: "Authenticating user via password", - extra: "undefined" + extra: "undefined", }); - } catch (e) { logger.logRequestFailure({ client: client?._id, @@ -63,7 +62,7 @@ router description: "Authenticating user via password", extra: "undefined", message: e.message, - stack: e.stack + stack: e.stack, }); g_lib.handleException(e, res); } @@ -103,9 +102,8 @@ router routePath: basePath + "/authn/token", status: "Success", description: "Authenticating user via access token", - extra: "undefined" + extra: "undefined", }); - } catch (e) { logger.logRequestFailure({ client: user?._id, @@ -116,7 +114,7 @@ router description: "Authenticating user via access token", extra: "undefined", message: e.message, - stack: e.stack + stack: e.stack, }); g_lib.handleException(e, res); From e56fd341929a2ed97113cf548472f7fdbc48eca2 Mon Sep 17 00:00:00 2001 From: Austin Hampton Date: Tue, 23 Sep 2025 11:33:11 -0400 Subject: [PATCH 16/36] refactor: replaced undefined with null for appropriate areas; made slight changes to some log output to obfuscate sensitive data --- core/database/foxx/api/user_router.js | 72 ++++++++++++--------------- 1 file changed, 32 insertions(+), 40 deletions(-) diff --git a/core/database/foxx/api/user_router.js b/core/database/foxx/api/user_router.js index f8a4ec81e..6cb2dee02 100644 --- a/core/database/foxx/api/user_router.js +++ b/core/database/foxx/api/user_router.js @@ -19,7 +19,7 @@ module.exports = router; router .get("/authn/password", function (req, res) { - let client = undefined; + let client = null; console.log("Running /authn/password"); try { client = g_lib.getUserFromClientID(req.queryParams.client); @@ -74,7 +74,7 @@ router router .get("/authn/token", function (req, res) { - let user = undefined; + let user = null; try { user = g_db._query("for i in u filter i.access == @tok return i", { tok: req.queryParams.token, @@ -126,8 +126,8 @@ router router .get("/create", function (req, res) { - let user = undefined; - let result = undefined; + let user = null; + let result = null; try { g_db._executeTransaction({ collections: { @@ -273,6 +273,7 @@ router delete user.new.name; result = [user.new]; + delete user.new.password; }, }); res.send(result); @@ -317,18 +318,9 @@ router router .get("/update", function (req, res) { - let client = undefined; - let result = undefined; + let client = null; + let result = null; try { - logger.logRequestStarted({ - client: user?._id, - correlationId: req.headers["x-correlation-id"], - httpVerb: "GET", - routePath: basePath + "/create", - status: "Started", - description: "Create new user entry", - }); - g_db._executeTransaction({ collections: { read: ["u", "uuid", "accn"], @@ -441,7 +433,7 @@ router router .get("/find/by_uuids", function (req, res) { - let user = undefined; + let user = null; try { // Convert UUIDs to DB _ids var uuids = []; @@ -505,7 +497,7 @@ router router .get("/find/by_name_uid", function (req, res) { - let name = undefined; + let name = null; try { name = req.queryParams.name_uid.trim(); logger.logRequestStarted({ @@ -580,7 +572,7 @@ router router .get("/keys/set", function (req, res) { - let client = undefined; + let client = null; try { g_db._executeTransaction({ collections: { @@ -653,7 +645,7 @@ router router .get("/keys/clear", function (req, res) { - let client = undefined; + let client = null; try { g_db._executeTransaction({ collections: { @@ -722,7 +714,7 @@ router router .get("/keys/get", function (req, res) { - let user = undefined; + let user = null; try { if (req.queryParams.subject) { if (!g_db.u.exists(req.queryParams.subject)) @@ -800,7 +792,7 @@ router router .get("/find/by_pub_key", function (req, res) { - let uid = undefined; + let uid = null; try { uid = g_lib.uidFromPubKey(req.queryParams.pub_key); logger.logRequestStarted({ @@ -842,7 +834,7 @@ router router .get("/token/set", function (req, res) { - let client = undefined; + let client = null; try { g_db._executeTransaction({ collections: { @@ -1030,7 +1022,7 @@ router router .get("/token/get", function (req, res) { - let user = undefined; + let user = null; try { const collection_token = UserToken.validateRequestParams(req.queryParams); // TODO: collection type determines logic when mapped vs HA @@ -1116,7 +1108,7 @@ router router .get("/token/get/access", function (req, res) { - let user = undefined; + let user = null; try { if (req.queryParams.subject) { if (!g_db.u.exists(req.queryParams.subject)) @@ -1149,7 +1141,7 @@ router routePath: basePath + "/token/get/access", status: "Success", description: "Getting User Access Token", - extra: user.access, + extra: "undefined", }); } catch (e) { logger.logRequestFailure({ @@ -1159,7 +1151,7 @@ router routePath: basePath + "/token/get/access", status: "Failure", description: "Getting User Access Token", - extra: user.access, + extra: "undefined", message: e.message, stack: e.stack, }); @@ -1174,8 +1166,8 @@ router router .get("/token/get/expiring", function (req, res) { - let user = undefined; - let result = undefined; + let user = null; + let result = null; try { //console.log("exp:",(Date.now()/1000) + req.queryParams.expires_in); logger.logRequestStarted({ @@ -1225,7 +1217,7 @@ router router .get("/view", function (req, res) { - let client = undefined; + let client = null; try { client = g_lib.getUserFromClientID_noexcept(req.queryParams.client); logger.logRequestStarted({ @@ -1323,8 +1315,8 @@ router routePath: basePath + "/view", status: "Success", description: "View User Information", - extra: req.queryParams.details ? client : "undefined", - }); + extra: user, + }); //req.queryParams.details ? } catch (e) { g_lib.handleException(e, res); logger.logRequestFailure({ @@ -1334,7 +1326,7 @@ router routePath: basePath + "/view", status: "Failure", description: "View User Information", - extra: req.queryParams.details, + extra: user, message: e.message, stack: e.stack, }); @@ -1348,7 +1340,7 @@ router router .get("/list/all", function (req, res) { - let client = undefined; + let client = null; var qry = "for i in u sort i.name_last, i.name_first"; var result; logger.logRequestStarted({ @@ -1482,8 +1474,8 @@ Note: must delete ALL data records and projects owned by the user being deleted */ router .get("/delete", function (req, res) { - let client = undefined; - let user_id = undefined; + let client = null; + let user_id = null; try { g_db._executeTransaction({ collections: { @@ -1615,7 +1607,7 @@ router router .get("/ident/list", function (req, res) { - let client = undefined; + let client = null; try { client = g_lib.getUserFromClientID(req.queryParams.client); logger.logRequestStarted({ @@ -1683,7 +1675,7 @@ router router .get("/ident/add", function (req, res) { - let client = undefined; + let client = null; try { g_db._executeTransaction({ collections: { @@ -1831,7 +1823,7 @@ router router .get("/ident/remove", function (req, res) { - let client = undefined; + let client = null; try { g_db._executeTransaction({ collections: { @@ -1893,7 +1885,7 @@ router router .get("/ep/get", function (req, res) { - let client = undefined; + let client = null; try { client = g_lib.getUserFromClientID(req.queryParams.client); logger.logRequestStarted({ @@ -1936,7 +1928,7 @@ router router .get("/ep/set", function (req, res) { - let client = undefined; + let client = null; try { client = g_lib.getUserFromClientID(req.queryParams.client); logger.logRequestStarted({ From 244361dcc20c6de696fe922d237039a02ae3e0c5 Mon Sep 17 00:00:00 2001 From: Austin Hampton Date: Tue, 23 Sep 2025 13:16:11 -0400 Subject: [PATCH 17/36] refactor: Fixed spacing within logs; Removed unnecessary logging --- core/database/foxx/api/lib/logger.js | 8 ++++---- core/database/foxx/api/user_router.js | 21 +-------------------- 2 files changed, 5 insertions(+), 24 deletions(-) diff --git a/core/database/foxx/api/lib/logger.js b/core/database/foxx/api/lib/logger.js index 368c5b8f5..8039c3bca 100644 --- a/core/database/foxx/api/lib/logger.js +++ b/core/database/foxx/api/lib/logger.js @@ -25,7 +25,7 @@ function logRequestSuccess({ pad("Status", status) + " | " + pad("Desc", description) + - "|" + + " | " + pad("Extra", typeof extra === "object" ? JSON.stringify(extra) : extra), ); } @@ -56,11 +56,11 @@ function logRequestFailure({ pad("Status", status) + " | " + pad("Desc", description) + - "|" + + " | " + pad("Extra", typeof extra === "object" ? JSON.stringify(extra) : extra) + - "|" + + " | " + pad("Err", message) + - "|" + + " | " + pad("Stack", stack), ); } diff --git a/core/database/foxx/api/user_router.js b/core/database/foxx/api/user_router.js index 6cb2dee02..72d1b9fc0 100644 --- a/core/database/foxx/api/user_router.js +++ b/core/database/foxx/api/user_router.js @@ -20,7 +20,6 @@ module.exports = router; router .get("/authn/password", function (req, res) { let client = null; - console.log("Running /authn/password"); try { client = g_lib.getUserFromClientID(req.queryParams.client); const is_verified = auth.verify(client.password, req.queryParams.pw); @@ -36,9 +35,6 @@ router description: "Authenticating user via password", }); - //if ( client.password != req.queryParams.pw ) - // throw g_lib.ERR_AUTHN_FAILED; - res.send({ uid: client._id, authorized: true, @@ -886,14 +882,6 @@ router user_id = client._id; user_doc = client; } - console.log( - "updating tokens for", - user_id, - "acc:", - req.queryParams.access, - "exp:", - req.queryParams.expires_in, - ); var obj = { access: req.queryParams.access, refresh: req.queryParams.refresh, @@ -953,7 +941,6 @@ router ...obj, }; - console.log("writing to edge ", token_doc); const token_doc_upsert = g_db.globus_token.insert(token_doc, { overwriteMode: "replace", // TODO: perhaps use 'update' and specify values for true upsert. }); @@ -975,7 +962,7 @@ router status: "Success", description: "Setting user token", extra: "undefined", - }); + }); } }, }); @@ -1169,7 +1156,6 @@ router let user = null; let result = null; try { - //console.log("exp:",(Date.now()/1000) + req.queryParams.expires_in); logger.logRequestStarted({ client: user?._id, correlationId: req.headers["x-correlation-id"], @@ -1519,7 +1505,6 @@ router } else { user_id = client._id; } - //console.log( "delete user", user_id ); var objects, subobjects, obj, subobj, i, j; @@ -1531,7 +1516,6 @@ router .toArray(); for (i in objects) { obj = objects[i]; - //console.log( "del ident", obj ); g_graph[obj.substr(0, obj.indexOf("/"))].remove(obj); } @@ -1546,7 +1530,6 @@ router .toArray(); for (i in objects) { obj = objects[i]; - //console.log( "del proj", obj ); subobjects = g_db ._query("for v in 1..1 inbound @proj owner return v._id", { proj: obj, @@ -1554,7 +1537,6 @@ router .toArray(); for (j in subobjects) { subobj = subobjects[j]; - //console.log("del subobj",subobj); g_graph[subobj.substr(0, subobj.indexOf("/"))].remove(subobj); } @@ -1569,7 +1551,6 @@ router .toArray(); for (i in objects) { obj = objects[i]; - //console.log( "del owned", obj ); g_graph[obj.substr(0, obj.indexOf("/"))].remove(obj); } From 4a21c1a33cd6b8b1c52bfc344dbe5f62da6d780c Mon Sep 17 00:00:00 2001 From: Austin Hampton Date: Tue, 23 Sep 2025 15:34:32 +0000 Subject: [PATCH 18/36] chore: Auto-format JavaScript files with Prettier --- core/database/foxx/api/user_router.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/database/foxx/api/user_router.js b/core/database/foxx/api/user_router.js index 72d1b9fc0..365a6007b 100644 --- a/core/database/foxx/api/user_router.js +++ b/core/database/foxx/api/user_router.js @@ -1302,7 +1302,7 @@ router status: "Success", description: "View User Information", extra: user, - }); //req.queryParams.details ? + }); //req.queryParams.details ? } catch (e) { g_lib.handleException(e, res); logger.logRequestFailure({ From 38ce0a2bf647b1949b01b588558b1e495fa80270 Mon Sep 17 00:00:00 2001 From: Austin Hampton Date: Tue, 23 Sep 2025 17:27:09 +0000 Subject: [PATCH 19/36] chore: Auto-format JavaScript files with Prettier --- core/database/foxx/api/user_router.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/database/foxx/api/user_router.js b/core/database/foxx/api/user_router.js index 365a6007b..43c73af4c 100644 --- a/core/database/foxx/api/user_router.js +++ b/core/database/foxx/api/user_router.js @@ -962,7 +962,7 @@ router status: "Success", description: "Setting user token", extra: "undefined", - }); + }); } }, }); From a5c002f13bce13eb4f32a3c87689df3c5650d032 Mon Sep 17 00:00:00 2001 From: Austin Hampton Date: Thu, 14 Aug 2025 11:23:42 -0400 Subject: [PATCH 20/36] style: Removed non helpful logs from tasks.js --- external/protobuf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/external/protobuf b/external/protobuf index a9b006bdd..fff909ea5 160000 --- a/external/protobuf +++ b/external/protobuf @@ -1 +1 @@ -Subproject commit a9b006bddd52e289029f16aa77b77e8e0033d9ee +Subproject commit fff909ea5104ca2104898516511ee03ee4505078 From 161e0086a088abcaaae1a87c2ec789502b4f17da Mon Sep 17 00:00:00 2001 From: Austin Hampton Date: Fri, 22 Aug 2025 09:36:55 -0400 Subject: [PATCH 21/36] fix: reverted protobuf to match devel (a9b006) --- external/protobuf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/external/protobuf b/external/protobuf index fff909ea5..a9b006bdd 160000 --- a/external/protobuf +++ b/external/protobuf @@ -1 +1 @@ -Subproject commit fff909ea5104ca2104898516511ee03ee4505078 +Subproject commit a9b006bddd52e289029f16aa77b77e8e0033d9ee From 429d47c15e132692ad5c134e584df21cc3a8fbb2 Mon Sep 17 00:00:00 2001 From: Austin Hampton Date: Tue, 16 Sep 2025 15:55:26 +0000 Subject: [PATCH 22/36] chore: Auto-format JavaScript files with Prettier --- core/database/foxx/api/lib/logger.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/database/foxx/api/lib/logger.js b/core/database/foxx/api/lib/logger.js index 8039c3bca..3771255ee 100644 --- a/core/database/foxx/api/lib/logger.js +++ b/core/database/foxx/api/lib/logger.js @@ -71,7 +71,7 @@ function logRequestStarted({ client, correlationId, httpVerb, routePath, status, `${label}: ${value || "unknown"}`.padEnd(length, " "); console.info( - pad("Client", client) + + pad("Client", client) + " | " + pad("Correlation_ID", correlationId) + " | " + From 12b6ae198c546eee0026e71a70a65498a501abe7 Mon Sep 17 00:00:00 2001 From: Austin Hampton Date: Tue, 23 Sep 2025 13:16:11 -0400 Subject: [PATCH 23/36] refactor: Fixed spacing within logs; Removed unnecessary logging --- core/database/foxx/api/user_router.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/database/foxx/api/user_router.js b/core/database/foxx/api/user_router.js index 43c73af4c..365a6007b 100644 --- a/core/database/foxx/api/user_router.js +++ b/core/database/foxx/api/user_router.js @@ -962,7 +962,7 @@ router status: "Success", description: "Setting user token", extra: "undefined", - }); + }); } }, }); From d8ff808338f48b1f2213e3d5fd283cf0d56fe011 Mon Sep 17 00:00:00 2001 From: Austin Hampton Date: Tue, 23 Sep 2025 17:27:09 +0000 Subject: [PATCH 24/36] chore: Auto-format JavaScript files with Prettier --- core/database/foxx/api/user_router.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/database/foxx/api/user_router.js b/core/database/foxx/api/user_router.js index 365a6007b..43c73af4c 100644 --- a/core/database/foxx/api/user_router.js +++ b/core/database/foxx/api/user_router.js @@ -962,7 +962,7 @@ router status: "Success", description: "Setting user token", extra: "undefined", - }); + }); } }, }); From e17a3fab79e476664077d221fbb39c7b526e22ca Mon Sep 17 00:00:00 2001 From: Austin Hampton Date: Thu, 25 Sep 2025 13:22:15 +0000 Subject: [PATCH 25/36] chore: Auto-format JavaScript files with Prettier --- core/database/foxx/api/lib/logger.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/database/foxx/api/lib/logger.js b/core/database/foxx/api/lib/logger.js index 3771255ee..8039c3bca 100644 --- a/core/database/foxx/api/lib/logger.js +++ b/core/database/foxx/api/lib/logger.js @@ -71,7 +71,7 @@ function logRequestStarted({ client, correlationId, httpVerb, routePath, status, `${label}: ${value || "unknown"}`.padEnd(length, " "); console.info( - pad("Client", client) + + pad("Client", client) + " | " + pad("Correlation_ID", correlationId) + " | " + From cdde839f370a2a54ae2a32fff043d78991d3dddc Mon Sep 17 00:00:00 2001 From: Austin Hampton <44103380+megatnt1122@users.noreply.github.com> Date: Tue, 30 Sep 2025 14:22:18 -0400 Subject: [PATCH 26/36] Style: Corrected status' on logs Co-authored-by: Joshua S Brown --- core/database/foxx/api/user_router.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/core/database/foxx/api/user_router.js b/core/database/foxx/api/user_router.js index 43c73af4c..8344dc85a 100644 --- a/core/database/foxx/api/user_router.js +++ b/core/database/foxx/api/user_router.js @@ -54,7 +54,7 @@ router correlationId: req.headers["x-correlation-id"], httpVerb: "GET", routePath: basePath + "/authn/password", - status: "Success", + status: "Failure", description: "Authenticating user via password", extra: "undefined", message: e.message, @@ -468,7 +468,7 @@ router correlationId: req.headers["x-correlation-id"], httpVerb: "GET", routePath: basePath + "/find/by_uuids", - status: "Started", + status: "Success", description: "Find a user from list of UUIDs", extra: req.queryParams.uuids, }); @@ -1373,7 +1373,7 @@ router correlationId: req.headers["x-correlation-id"], httpVerb: "GET", routePath: basePath + "/list/all", - status: "Started", + status: "Success", description: "List all users", extra: result, }); @@ -1441,7 +1441,7 @@ router correlationId: req.headers["x-correlation-id"], httpVerb: "GET", routePath: basePath + "/list/collab", - status: "Started", + status: "Success", description: "List collaborators of client", extra: result, }); @@ -1850,7 +1850,7 @@ router correlationId: req.headers["x-correlation-id"], httpVerb: "GET", routePath: basePath + "/ident/remove", - status: "Success", + status: "Failure", description: "Remove linked identity from user account", extra: req.queryParams.ident, message: e.message, @@ -1944,7 +1944,7 @@ router correlationId: req.headers["x-correlation-id"], httpVerb: "GET", routePath: basePath + "/ep/set", - status: "Started", + status: "Failure", description: "Set recent end-points", extra: client.eps, message: e.message, From 7c3c01202764b392a44972c6c29c8ae3fd94aaea Mon Sep 17 00:00:00 2001 From: Austin Hampton Date: Thu, 2 Oct 2025 12:59:25 -0400 Subject: [PATCH 27/36] refactor:Second pass of user_router logging --- core/database/foxx/api/user_router.js | 63 +++++++++------------------ 1 file changed, 21 insertions(+), 42 deletions(-) diff --git a/core/database/foxx/api/user_router.js b/core/database/foxx/api/user_router.js index 8344dc85a..7a47f43cb 100644 --- a/core/database/foxx/api/user_router.js +++ b/core/database/foxx/api/user_router.js @@ -57,8 +57,7 @@ router status: "Failure", description: "Authenticating user via password", extra: "undefined", - message: e.message, - stack: e.stack, + error: e, }); g_lib.handleException(e, res); } @@ -109,8 +108,7 @@ router status: "Failure", description: "Authenticating user via access token", extra: "undefined", - message: e.message, - stack: e.stack, + error: e, }); g_lib.handleException(e, res); @@ -291,8 +289,7 @@ router status: "Failure", description: "Create new user entry", extra: result, - message: e.message, - stack: e.stack, + error: e, }); g_lib.handleException(e, res); } @@ -411,8 +408,7 @@ router status: "Failure", description: "Update user information", extra: result, - message: e.message, - stack: e.stack, + error: e, }); g_lib.handleException(e, res); } @@ -481,8 +477,7 @@ router status: "Failure", description: "Find a user from list of UUIDs", extra: req.queryParams.uuids, - message: e.message, - stack: e.stack, + error: e, }); g_lib.handleException(e, res); } @@ -554,8 +549,7 @@ router status: "Failure", description: "Find users matching partial name and/or uid", extra: result, - message: e.message, - stack: e.stack, + error: e, }); g_lib.handleException(e, res); } @@ -626,8 +620,7 @@ router status: "Failure", description: "Set user public and private keys", extra: "undefined", - message: e.message, - stack: e.stack, + error: e, }); g_lib.handleException(e, res); } @@ -697,8 +690,7 @@ router status: "Failure", description: "Clear user public and private keys", extra: "undefined", - message: e.message, - stack: e.stack, + error: e, }); g_lib.handleException(e, res); } @@ -775,8 +767,7 @@ router status: "Failure", description: "Get user public and private keys", extra: "undefined", - message: e.message, - stack: e.stack, + error: e, }); g_lib.handleException(e, res); } @@ -818,8 +809,7 @@ router status: "Failure", description: "Find a user by public key", extra: uid, - message: e.message, - stack: e.stack, + error: e, }); g_lib.handleException(e, res); } @@ -975,8 +965,7 @@ router status: "Failure", description: "Setting user tokens", extra: "undefined", - message: e.message, - stack: e.stack, + error: e, }); g_lib.handleException(e, res); } @@ -1072,8 +1061,7 @@ router status: "Failure", description: "Getting user tokens", extra: "undefined", - message: e.message, - stack: e.stack, + error: e, }); g_lib.handleException(e, res); } @@ -1139,8 +1127,7 @@ router status: "Failure", description: "Getting User Access Token", extra: "undefined", - message: e.message, - stack: e.stack, + error: e, }); g_lib.handleException(e, res); @@ -1190,8 +1177,7 @@ router status: "Failure", description: "Getting expiring user access token", extra: result, - message: e.message, - stack: e.stack, + error: e, }); g_lib.handleException(e, res); } @@ -1313,8 +1299,7 @@ router status: "Failure", description: "View User Information", extra: user, - message: e.message, - stack: e.stack, + error: e, }); } }) @@ -1575,8 +1560,7 @@ router status: "Failure", description: "Remove existing user entry", extra: user_id, - message: e.message, - stack: e.stack, + error: e, }); g_lib.handleException(e, res); } @@ -1644,8 +1628,7 @@ router routePath: basePath + "/ident/list", status: "Failure", description: "List user linked IDs", - message: e.message, - stack: e.stack, + error: e, }); g_lib.handleException(e, res); } @@ -1786,8 +1769,7 @@ router status: "Failure", description: "Add new linked identity", extra: req.queryParams.ident, - message: e.message, - stack: e.stack, + error: e, }); g_lib.handleException(e, res); } @@ -1853,8 +1835,7 @@ router status: "Failure", description: "Remove linked identity from user account", extra: req.queryParams.ident, - message: e.message, - stack: e.stack, + error: e, }); g_lib.handleException(e, res); } @@ -1897,8 +1878,7 @@ router status: "Failure", description: "Get recent end-points", extra: client.eps, - message: e.message, - stack: e.stack, + error: e, }); g_lib.handleException(e, res); } @@ -1947,8 +1927,7 @@ router status: "Failure", description: "Set recent end-points", extra: client.eps, - message: e.message, - stack: e.stack, + error: e, }); g_lib.handleException(e, res); } From be50c6bf2a811cd9c0cde15a59ffcdef122c76d9 Mon Sep 17 00:00:00 2001 From: Austin Hampton Date: Thu, 2 Oct 2025 13:11:27 -0400 Subject: [PATCH 28/36] refactor: Removed temporary logger file --- .gitmodules | 3 - core/database/foxx/api/lib/logger.js | 93 ---------------------------- 2 files changed, 96 deletions(-) delete mode 100644 core/database/foxx/api/lib/logger.js diff --git a/.gitmodules b/.gitmodules index bd31a9653..a7921d851 100644 --- a/.gitmodules +++ b/.gitmodules @@ -4,6 +4,3 @@ [submodule "external/protobuf"] path = external/protobuf url = https://github.com/protocolbuffers/protobuf.git -[submodule "external/DataFedDependencies"] - path = external/DataFedDependencies - url = https://github.com/ORNL/DataFedDependencies.git diff --git a/core/database/foxx/api/lib/logger.js b/core/database/foxx/api/lib/logger.js deleted file mode 100644 index 8039c3bca..000000000 --- a/core/database/foxx/api/lib/logger.js +++ /dev/null @@ -1,93 +0,0 @@ -"use strict"; - -function logRequestSuccess({ - client, - correlationId, - httpVerb, - routePath, - status, - description, - extra, -}) { - // helper to pad fields - const pad = (label, value, length = 20) => - `${label}: ${value || "unknown"}`.padEnd(length, " "); - - console.info( - pad("Client", client) + - " | " + - pad("Correlation_ID", correlationId) + - " | " + - pad("HTTP", httpVerb) + - " | " + - pad("Route", routePath) + - " | " + - pad("Status", status) + - " | " + - pad("Desc", description) + - " | " + - pad("Extra", typeof extra === "object" ? JSON.stringify(extra) : extra), - ); -} - -function logRequestFailure({ - client, - correlationId, - httpVerb, - routePath, - status, - description, - extra, - message, - stack, -}) { - // helper to pad fields - const pad = (label, value, length = 20) => - `${label}: ${value || "unknown"}`.padEnd(length, " "); - console.error( - pad("Client", client) + - " | " + - pad("Correlation_ID", correlationId) + - " | " + - pad("HTTP", httpVerb) + - " | " + - pad("Route", routePath) + - " | " + - pad("Status", status) + - " | " + - pad("Desc", description) + - " | " + - pad("Extra", typeof extra === "object" ? JSON.stringify(extra) : extra) + - " | " + - pad("Err", message) + - " | " + - pad("Stack", stack), - ); -} - -function logRequestStarted({ client, correlationId, httpVerb, routePath, status, description }) { - // helper to pad fields - const pad = (label, value, length = 20) => - `${label}: ${value || "unknown"}`.padEnd(length, " "); - - console.info( - pad("Client", client) + - " | " + - pad("Correlation_ID", correlationId) + - " | " + - pad("HTTP", httpVerb) + - " | " + - pad("Route", routePath) + - " | " + - pad("Status", status) + - " | " + - pad("Desc", description), - ); -} - -// Export the functions -module.exports = { - logRequestSuccess, - logRequestFailure, - logRequestStarted, -}; From 3e7e27bd841d1555691d579f0005b80c2a418e0c Mon Sep 17 00:00:00 2001 From: Austin Hampton Date: Thu, 2 Oct 2025 13:18:52 -0400 Subject: [PATCH 29/36] refactor:removed external/protobuf --- .gitmodules | 3 --- external/protobuf | 1 - 2 files changed, 4 deletions(-) delete mode 160000 external/protobuf diff --git a/.gitmodules b/.gitmodules index a7921d851..e183f8616 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,6 +1,3 @@ [submodule "external/globus-connect-server-deploy"] path = external/globus-connect-server-deploy url = https://github.com/globus/globus-connect-server-deploy.git -[submodule "external/protobuf"] - path = external/protobuf - url = https://github.com/protocolbuffers/protobuf.git diff --git a/external/protobuf b/external/protobuf deleted file mode 160000 index a9b006bdd..000000000 --- a/external/protobuf +++ /dev/null @@ -1 +0,0 @@ -Subproject commit a9b006bddd52e289029f16aa77b77e8e0033d9ee From 1678a95e40a32ee18a86390518393ba6f2903425 Mon Sep 17 00:00:00 2001 From: Austin Hampton Date: Mon, 6 Oct 2025 15:24:37 -0400 Subject: [PATCH 30/36] refactor: Final touches for logging --- core/database/foxx/api/user_router.js | 28 ++++++++++++++------------- external/DataFedDependencies | 2 +- 2 files changed, 16 insertions(+), 14 deletions(-) diff --git a/core/database/foxx/api/user_router.js b/core/database/foxx/api/user_router.js index 3620d5dad..324b1cd76 100644 --- a/core/database/foxx/api/user_router.js +++ b/core/database/foxx/api/user_router.js @@ -944,18 +944,20 @@ router g_db._update(user_id, obj, { keepNull: false, }); - break; - } - logger.logRequestSuccess({ - client: client?._id, - correlationId: req.headers["x-correlation-id"], - httpVerb: "GET", - routePath: basePath + "/token/set", - status: "Success", - description: "Setting user token", - extra: "undefined", - }); + break; + } } + const tokenTypeName = Object.keys(g_lib.AccessTokenType).find( key => g_lib.AccessTokenType[key] === token_type); + + logger.logRequestSuccess({ + client: client?._id, + correlationId: req.headers["x-correlation-id"], + httpVerb: "GET", + routePath: basePath + "/token/set", + status: "Success", + description: "Setting user token", + extra: `${tokenTypeName} (${token_type})`, + }); }, }); } catch (e) { @@ -1289,7 +1291,7 @@ router routePath: basePath + "/view", status: "Success", description: "View User Information", - extra: user, + extra: user._id, }); //req.queryParams.details ? } catch (e) { g_lib.handleException(e, res); @@ -1300,7 +1302,7 @@ router routePath: basePath + "/view", status: "Failure", description: "View User Information", - extra: user, + extra: user._id, error: e, }); } diff --git a/external/DataFedDependencies b/external/DataFedDependencies index 57483e1cd..b3528638d 160000 --- a/external/DataFedDependencies +++ b/external/DataFedDependencies @@ -1 +1 @@ -Subproject commit 57483e1cd4eac9d84162dd7202e72fe353728361 +Subproject commit b3528638dc7e78633b60b607fd0227aa5862bf53 From e6e4617fecef0d27a11be142e0239987947a22cb Mon Sep 17 00:00:00 2001 From: Austin Hampton Date: Mon, 6 Oct 2025 19:25:22 +0000 Subject: [PATCH 31/36] chore: Auto-format JavaScript files with Prettier --- core/database/foxx/api/user_router.js | 31 ++++++++++++++------------- 1 file changed, 16 insertions(+), 15 deletions(-) diff --git a/core/database/foxx/api/user_router.js b/core/database/foxx/api/user_router.js index 324b1cd76..ee6216c08 100644 --- a/core/database/foxx/api/user_router.js +++ b/core/database/foxx/api/user_router.js @@ -938,26 +938,27 @@ router }); break; } - case g_lib.AccessTokenType.GLOBUS_DEFAULT: - { - // Existing logic, default actions - g_db._update(user_id, obj, { - keepNull: false, - }); + case g_lib.AccessTokenType.GLOBUS_DEFAULT: { + // Existing logic, default actions + g_db._update(user_id, obj, { + keepNull: false, + }); break; } } - const tokenTypeName = Object.keys(g_lib.AccessTokenType).find( key => g_lib.AccessTokenType[key] === token_type); + const tokenTypeName = Object.keys(g_lib.AccessTokenType).find( + (key) => g_lib.AccessTokenType[key] === token_type, + ); logger.logRequestSuccess({ - client: client?._id, - correlationId: req.headers["x-correlation-id"], - httpVerb: "GET", - routePath: basePath + "/token/set", - status: "Success", - description: "Setting user token", - extra: `${tokenTypeName} (${token_type})`, - }); + client: client?._id, + correlationId: req.headers["x-correlation-id"], + httpVerb: "GET", + routePath: basePath + "/token/set", + status: "Success", + description: "Setting user token", + extra: `${tokenTypeName} (${token_type})`, + }); }, }); } catch (e) { From d8b05eb2748a6099f0d304a3a727c2461cc3b68d Mon Sep 17 00:00:00 2001 From: Austin Hampton Date: Tue, 7 Oct 2025 09:11:42 -0400 Subject: [PATCH 32/36] refactor: Cleaning up PII issues --- core/database/foxx/api/user_router.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/core/database/foxx/api/user_router.js b/core/database/foxx/api/user_router.js index 324b1cd76..138feb16a 100644 --- a/core/database/foxx/api/user_router.js +++ b/core/database/foxx/api/user_router.js @@ -280,7 +280,7 @@ router routePath: basePath + "/create", status: "Success", description: "Create new user entry", - extra: result, + extra: user.new.uid, }); } catch (e) { logger.logRequestFailure({ @@ -290,7 +290,7 @@ router routePath: basePath + "/create", status: "Failure", description: "Create new user entry", - extra: result, + extra: user.new.uid, error: e, }); g_lib.handleException(e, res); @@ -1291,7 +1291,7 @@ router routePath: basePath + "/view", status: "Success", description: "View User Information", - extra: user._id, + extra: `uid=${user._id}, is_admin=${!!client?.is_admin}`, }); //req.queryParams.details ? } catch (e) { g_lib.handleException(e, res); @@ -1302,7 +1302,7 @@ router routePath: basePath + "/view", status: "Failure", description: "View User Information", - extra: user._id, + extra: `uid=${user._id}, is_admin=${!!client?.is_admin}`, error: e, }); } From 3b16211e327239fa4f6e9c026c826d9d0348a6c0 Mon Sep 17 00:00:00 2001 From: Austin Hampton Date: Tue, 7 Oct 2025 10:21:02 -0400 Subject: [PATCH 33/36] refactor:Final checks, changed /view's extra output --- core/database/foxx/api/user_router.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/core/database/foxx/api/user_router.js b/core/database/foxx/api/user_router.js index b6aa1d6ca..ccd585f1d 100644 --- a/core/database/foxx/api/user_router.js +++ b/core/database/foxx/api/user_router.js @@ -1292,7 +1292,7 @@ router routePath: basePath + "/view", status: "Success", description: "View User Information", - extra: `uid=${user._id}, is_admin=${!!client?.is_admin}`, + extra: `uid=${user.uid}, is_admin=${!!client?.is_admin}`, }); //req.queryParams.details ? } catch (e) { g_lib.handleException(e, res); @@ -1303,7 +1303,7 @@ router routePath: basePath + "/view", status: "Failure", description: "View User Information", - extra: `uid=${user._id}, is_admin=${!!client?.is_admin}`, + extra: `uid=${user.uid}, is_admin=${!!client?.is_admin}`, error: e, }); } From b201113f1318f492bcf1bf0f58c8a96fdc9c0072 Mon Sep 17 00:00:00 2001 From: Austin Hampton Date: Tue, 7 Oct 2025 14:43:21 -0400 Subject: [PATCH 34/36] Submodule update --- external/DataFedDependencies | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/external/DataFedDependencies b/external/DataFedDependencies index b3528638d..57483e1cd 160000 --- a/external/DataFedDependencies +++ b/external/DataFedDependencies @@ -1 +1 @@ -Subproject commit b3528638dc7e78633b60b607fd0227aa5862bf53 +Subproject commit 57483e1cd4eac9d84162dd7202e72fe353728361 From b309d82c8bc4ed8b1036f3697fb3f1532cf4daa2 Mon Sep 17 00:00:00 2001 From: Austin Hampton Date: Wed, 8 Oct 2025 07:57:43 -0400 Subject: [PATCH 35/36] refactor: Commited all reviewed changes --- core/database/foxx/api/user_router.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/core/database/foxx/api/user_router.js b/core/database/foxx/api/user_router.js index ccd585f1d..3bf88e029 100644 --- a/core/database/foxx/api/user_router.js +++ b/core/database/foxx/api/user_router.js @@ -743,7 +743,7 @@ router description: "Get user public and private keys", extra: "undefined", }); - } else + } else { res.send([ { uid: user._id, @@ -760,6 +760,7 @@ router description: "Get user public and private keys", extra: "undefined", }); + } } catch (e) { logger.logRequestFailure({ client: user?._id, @@ -1426,7 +1427,7 @@ router } res.send(result); - logger.logRequestSucceed({ + logger.logRequestSuccess({ client: client?._id, correlationId: req.headers["x-correlation-id"], httpVerb: "GET", From 6bed208a1b84f56773a074873d148081a397881c Mon Sep 17 00:00:00 2001 From: Austin Hampton Date: Wed, 8 Oct 2025 11:58:56 +0000 Subject: [PATCH 36/36] chore: Auto-format JavaScript files with Prettier --- core/database/foxx/api/user_router.js | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/core/database/foxx/api/user_router.js b/core/database/foxx/api/user_router.js index 3bf88e029..ad1fbf770 100644 --- a/core/database/foxx/api/user_router.js +++ b/core/database/foxx/api/user_router.js @@ -751,15 +751,15 @@ router priv_key: user.priv_key, }, ]); - logger.logRequestSuccess({ - client: user?._id, - correlationId: req.headers["x-correlation-id"], - httpVerb: "GET", - routePath: basePath + "/keys/get", - status: "Success", - description: "Get user public and private keys", - extra: "undefined", - }); + logger.logRequestSuccess({ + client: user?._id, + correlationId: req.headers["x-correlation-id"], + httpVerb: "GET", + routePath: basePath + "/keys/get", + status: "Success", + description: "Get user public and private keys", + extra: "undefined", + }); } } catch (e) { logger.logRequestFailure({