#5 replace all console.logs with debugger
All checks were successful
DRB Tests / drb_mocha_tests (pull_request) Successful in 32s
All checks were successful
DRB Tests / drb_mocha_tests (pull_request) Successful in 32s
This commit is contained in:
@@ -1,3 +1,5 @@
|
||||
import { DebugBuilder } from "../../modules/debugger.mjs";
|
||||
const log = new DebugBuilder("server", "mongoDiscordIDWrappers");
|
||||
import { insertDocument, getDocuments, connectToDatabase } from "./mongoHandler.mjs";
|
||||
|
||||
const collectionName = 'discord-ids';
|
||||
@@ -8,7 +10,7 @@ export const createDiscordID = async (discordID) => {
|
||||
const insertedId = await insertDocument(collectionName, discordID);
|
||||
return insertedId;
|
||||
} catch (error) {
|
||||
console.error('Error creating Discord ID:', error);
|
||||
log.ERROR('Error creating Discord ID:', error);
|
||||
throw error;
|
||||
}
|
||||
};
|
||||
@@ -19,7 +21,7 @@ export const getAllDiscordIDs = async () => {
|
||||
const discordIDs = await getDocuments(collectionName);
|
||||
return discordIDs;
|
||||
} catch (error) {
|
||||
console.error('Error getting all Discord IDs:', error);
|
||||
log.ERROR('Error getting all Discord IDs:', error);
|
||||
throw error;
|
||||
}
|
||||
};
|
||||
@@ -37,7 +39,7 @@ export const getDiscordID = async (identifier) => {
|
||||
});
|
||||
return discordID;
|
||||
} catch (error) {
|
||||
console.error('Error getting Discord ID:', error);
|
||||
log.ERROR('Error getting Discord ID:', error);
|
||||
throw error;
|
||||
} finally {
|
||||
// Close the connection
|
||||
@@ -56,10 +58,10 @@ export const updateDiscordID = async (identifier, updatedFields) => {
|
||||
{ discord_id: identifier }
|
||||
]
|
||||
}, { $set: updatedFields });
|
||||
console.log('Discord ID updated:', result.modifiedCount);
|
||||
log.INFO('Discord ID updated:', result.modifiedCount);
|
||||
return result.modifiedCount;
|
||||
} catch (error) {
|
||||
console.error('Error updating Discord ID:', error);
|
||||
log.ERROR('Error updating Discord ID:', error);
|
||||
throw error;
|
||||
} finally {
|
||||
// Close the connection
|
||||
@@ -78,10 +80,10 @@ export const deleteDiscordID = async (identifier) => {
|
||||
{ discord_id: identifier }
|
||||
]
|
||||
});
|
||||
console.log('Discord ID deleted:', result.deletedCount);
|
||||
log.INFO('Discord ID deleted:', result.deletedCount);
|
||||
return result.deletedCount;
|
||||
} catch (error) {
|
||||
console.error('Error deleting Discord ID:', error);
|
||||
log.ERROR('Error deleting Discord ID:', error);
|
||||
throw error;
|
||||
} finally {
|
||||
// Close the connection
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
import { DebugBuilder } from "../../modules/debugger.mjs";
|
||||
const log = new DebugBuilder("server", "mongoFeedsWrappers");
|
||||
import {
|
||||
insertDocument,
|
||||
getDocuments,
|
||||
@@ -15,7 +17,7 @@ import {
|
||||
const insertedId = await insertDocument(feedCollectionName, feed);
|
||||
return insertedId;
|
||||
} catch (error) {
|
||||
console.error('Error creating feed:', error);
|
||||
log.ERROR('Error creating feed:', error);
|
||||
throw error;
|
||||
}
|
||||
};
|
||||
@@ -26,7 +28,7 @@ import {
|
||||
const feeds = await getDocuments(feedCollectionName);
|
||||
return feeds;
|
||||
} catch (error) {
|
||||
console.error('Error getting all feeds:', error);
|
||||
log.ERROR('Error getting all feeds:', error);
|
||||
throw error;
|
||||
}
|
||||
};
|
||||
@@ -37,7 +39,7 @@ import {
|
||||
const feed = await getDocumentByField(feedCollectionName, 'link', link);
|
||||
return feed;
|
||||
} catch (error) {
|
||||
console.error('Error getting feed by link:', error);
|
||||
log.ERROR('Error getting feed by link:', error);
|
||||
throw error;
|
||||
}
|
||||
};
|
||||
@@ -48,7 +50,7 @@ import {
|
||||
const modifiedCount = await updateDocumentByField(feedCollectionName, 'link', link, updatedFields);
|
||||
return modifiedCount;
|
||||
} catch (error) {
|
||||
console.error('Error updating feed by link:', error);
|
||||
log.ERROR('Error updating feed by link:', error);
|
||||
throw error;
|
||||
}
|
||||
};
|
||||
@@ -59,7 +61,7 @@ import {
|
||||
const deletedCount = await deleteDocumentByField(feedCollectionName, 'link', link);
|
||||
return deletedCount;
|
||||
} catch (error) {
|
||||
console.error('Error deleting feed by link:', error);
|
||||
log.ERROR('Error deleting feed by link:', error);
|
||||
throw error;
|
||||
}
|
||||
};
|
||||
@@ -70,7 +72,7 @@ import {
|
||||
const insertedId = await insertDocument(postCollectionName, post);
|
||||
return insertedId;
|
||||
} catch (error) {
|
||||
console.error('Error creating post:', error);
|
||||
log.ERROR('Error creating post:', error);
|
||||
throw error;
|
||||
}
|
||||
};
|
||||
@@ -81,7 +83,7 @@ import {
|
||||
const post = await getDocumentByField(postCollectionName, 'postId', postId);
|
||||
return post;
|
||||
} catch (error) {
|
||||
console.error('Error getting post by postId:', error);
|
||||
log.ERROR('Error getting post by postId:', error);
|
||||
throw error;
|
||||
}
|
||||
};
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
import { DebugBuilder } from "../../modules/debugger.mjs";
|
||||
const log = new DebugBuilder("server", "mongoNodesWrappers");
|
||||
import { insertDocument, getDocuments, connectToDatabase } from "./mongoHandler.mjs";
|
||||
|
||||
const collectionName = 'nodes';
|
||||
@@ -8,7 +10,7 @@ export const createNode = async (node) => {
|
||||
const insertedId = await insertDocument(collectionName, node);
|
||||
return insertedId;
|
||||
} catch (error) {
|
||||
console.error('Error creating node:', error);
|
||||
log.ERROR('Error creating node:', error);
|
||||
throw error;
|
||||
}
|
||||
};
|
||||
@@ -19,7 +21,7 @@ export const getAllNodes = async () => {
|
||||
const nodes = await getDocuments(collectionName);
|
||||
return nodes;
|
||||
} catch (error) {
|
||||
console.error('Error getting all nodes:', error);
|
||||
log.ERROR('Error getting all nodes:', error);
|
||||
throw error;
|
||||
}
|
||||
};
|
||||
@@ -32,7 +34,7 @@ export const getNodeByNuid = async (nuid) => {
|
||||
const node = await collection.findOne({ nuid });
|
||||
return node;
|
||||
} catch (error) {
|
||||
console.error('Error getting node by NUID:', error);
|
||||
log.ERROR('Error getting node by NUID:', error);
|
||||
throw error;
|
||||
} finally {
|
||||
// Close the connection
|
||||
@@ -46,10 +48,10 @@ export const updateNodeByNuid = async (nuid, updatedFields) => {
|
||||
try {
|
||||
const collection = db.db().collection(collectionName);
|
||||
const result = await collection.updateOne({ nuid }, { $set: updatedFields });
|
||||
console.log('Node updated:', result.modifiedCount);
|
||||
log.INFO('Node updated:', result.modifiedCount);
|
||||
return result.modifiedCount;
|
||||
} catch (error) {
|
||||
console.error('Error updating node by NUID:', error);
|
||||
log.ERROR('Error updating node by NUID:', error);
|
||||
throw error;
|
||||
} finally {
|
||||
// Close the connection
|
||||
@@ -63,10 +65,10 @@ export const deleteNodeByNuid = async (nuid) => {
|
||||
try {
|
||||
const collection = db.db().collection(collectionName);
|
||||
const result = await collection.deleteOne({ nuid });
|
||||
console.log('Node deleted:', result.deletedCount);
|
||||
log.INFO('Node deleted:', result.deletedCount);
|
||||
return result.deletedCount;
|
||||
} catch (error) {
|
||||
console.error('Error deleting node by NUID:', error);
|
||||
log.ERROR('Error deleting node by NUID:', error);
|
||||
throw error;
|
||||
} finally {
|
||||
// Close the connection
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
import { DebugBuilder } from "../../modules/debugger.mjs";
|
||||
const log = new DebugBuilder("server", "mongoSystemsWrappers");
|
||||
import { insertDocument, getDocuments, connectToDatabase } from "./mongoHandler.mjs";
|
||||
|
||||
const collectionName = 'radio-systems';
|
||||
@@ -21,7 +23,7 @@ export const createSystem = async (name, system, nuid) => {
|
||||
const insertedId = await insertDocument(collectionName, system);
|
||||
return insertedId;
|
||||
} catch (error) {
|
||||
console.error('Error creating system:', error);
|
||||
log.ERROR('Error creating system:', error);
|
||||
throw error;
|
||||
}
|
||||
};
|
||||
@@ -32,7 +34,7 @@ export const getAllSystems = async () => {
|
||||
const systems = await getDocuments(collectionName);
|
||||
return systems;
|
||||
} catch (error) {
|
||||
console.error('Error getting all systems:', error);
|
||||
log.ERROR('Error getting all systems:', error);
|
||||
throw error;
|
||||
}
|
||||
};
|
||||
@@ -45,7 +47,7 @@ export const getSystemByName = async (name) => {
|
||||
const system = await collection.findOne({ name });
|
||||
return system;
|
||||
} catch (error) {
|
||||
console.error('Error getting system by name:', error);
|
||||
log.ERROR('Error getting system by name:', error);
|
||||
throw error;
|
||||
} finally {
|
||||
// Close the connection
|
||||
@@ -65,7 +67,7 @@ export const getSystemsByNuid = async (nuid) => {
|
||||
|
||||
return systems;
|
||||
} catch (error) {
|
||||
console.error('Error finding entries:', error);
|
||||
log.ERROR('Error finding entries:', error);
|
||||
throw error;
|
||||
} finally {
|
||||
// Close the connection
|
||||
@@ -82,10 +84,10 @@ export const updateSystemByName = async (name, updatedSystem) => {
|
||||
try {
|
||||
const collection = db.db().collection(collectionName);
|
||||
const result = await collection.updateOne({ name }, { $set: updatedSystem });
|
||||
console.log('System updated:', result.modifiedCount);
|
||||
log.INFO('System updated:', result.modifiedCount);
|
||||
return result.modifiedCount;
|
||||
} catch (error) {
|
||||
console.error('Error updating system by name:', error);
|
||||
log.ERROR('Error updating system by name:', error);
|
||||
throw error;
|
||||
} finally {
|
||||
// Close the connection
|
||||
@@ -99,10 +101,10 @@ export const deleteSystemByName = async (name) => {
|
||||
try {
|
||||
const collection = db.db().collection(collectionName);
|
||||
const result = await collection.deleteOne({ name });
|
||||
console.log('System deleted:', result.deletedCount);
|
||||
log.INFO('System deleted:', result.deletedCount);
|
||||
return result.deletedCount;
|
||||
} catch (error) {
|
||||
console.error('Error deleting system by name:', error);
|
||||
log.ERROR('Error deleting system by name:', error);
|
||||
throw error;
|
||||
} finally {
|
||||
// Close the connection
|
||||
|
||||
Reference in New Issue
Block a user