Add function to get all client IDs from JSON file #7

This commit is contained in:
Logan Cusano
2023-06-04 00:24:50 -04:00
parent c6c048c919
commit fc11324714
2 changed files with 14 additions and 5 deletions

View File

@@ -1,6 +1,8 @@
// Debug
const { DebugBuilder } = require("../utilities/debugBuilder");
const { readFileSync } = require('fs');
const log = new DebugBuilder("server", "utils");
const path = require('path');
// Convert a JSON object to a buffer for the DB
exports.JsonToBuffer = (jsonObject) => {
@@ -72,4 +74,13 @@ exports.isJsonString = (str) => {
return false;
}
return true;
}
/**
* Get all client IDs from the saved JSON file
*
* @returns Object of Client IDs
*/
exports.getAllClientIds = () => {
return Object(JSON.parse(readFileSync(path.resolve(__dirname, '../clientIds.json'))));
}