diff --git a/Client/client.js b/Client/client.js index efd575240..211b0fa87 100644 --- a/Client/client.js +++ b/Client/client.js @@ -71,10 +71,18 @@ let WEB_SOCKETS_INTERFACE = require('./webSocketsServer.js') let HTTP_INTERFACE = require('./httpInterface.js') try { - /* Setting up the modules that will be available for the Servers Running inside this Client */ + /* + Setting up the modules that will be available for the Servers Running inside this Client + */ let MULTI_PROJECT = require('./MultiProject.js'); let MULTI_PROJECT_MODULE = MULTI_PROJECT.newMultiProject() MULTI_PROJECT_MODULE.initialize() + /* + Setting up external dependencies. + */ + CL.nodeModules = { + nodeFetch: require('node-fetch') + } console.log('CLIENT SERVERS:') console.log('') diff --git a/Client/githubServer.js b/Client/githubServer.js index 8bcfe0fab..9bec1d167 100644 --- a/Client/githubServer.js +++ b/Client/githubServer.js @@ -364,7 +364,7 @@ exports.newGithubServer = function newGithubServer() { continue } await CL.projects.foundations.utilities.asyncFunctions.sleep(GITHUB_API_WAITING_TIME) - let fileContent = await fetchAPIDataFile(fileContentUrl) + let fileContent = await CL.projects.foundations.utilities.webAccess.fetchAPIDataFile(fileContentUrl) let userProfile = JSON.parse(fileContent) /* diff --git a/Client/httpInterface.js b/Client/httpInterface.js index cabb56dae..58bb8e5fd 100644 --- a/Client/httpInterface.js +++ b/Client/httpInterface.js @@ -2062,38 +2062,4 @@ exports.newHttpInterface = function newHttpInterface( return files.reduce((a, f) => a.concat(f), []); } } - - async function fetchAPIDataFile(url) { - let promise = new Promise((resolve, reject) => { - - const fetch = require('node-fetch') - /* - This is how we call the API. - */ - fetch(url) - .then((response) => { - - if (response.status !== 200) { - console.log('[ERROR] fetchAPIData -> then -> url =' + url) - reject() - return - } - getResponseBody() - - function getResponseBody() { - response.text().then(body => { - resolve(body) - }) - } - }) - .catch(err => { - console.log('[ERROR] fetchAPIData -> url =' + url) - reject() - }) - - } - ) - - return promise - } } diff --git a/Projects/Foundations/CL/Utilities/WebAccess.js b/Projects/Foundations/CL/Utilities/WebAccess.js new file mode 100644 index 000000000..9e3879cc3 --- /dev/null +++ b/Projects/Foundations/CL/Utilities/WebAccess.js @@ -0,0 +1,40 @@ +exports.newFoundationsUtilitiesWebAccess = function () { + + let thisObject = { + fetchAPIDataFile: fetchAPIDataFile + } + + return thisObject + + async function fetchAPIDataFile(url) { + let promise = new Promise((resolve, reject) => { + + const fetch = CL.nodeModules.nodeFetch + /* + This is how we call the API. + */ + fetch(url) + .then((response) => { + + if (response.status !== 200) { + console.log('[ERROR] fetchAPIData -> then -> url =' + url) + reject() + return + } + getResponseBody() + + function getResponseBody() { + response.text().then(body => { + resolve(body) + }) + } + }) + .catch(err => { + console.log('[ERROR] fetchAPIData -> url =' + url) + reject() + }) + } + ) + return promise + } +} \ No newline at end of file diff --git a/Projects/Governance/Plugins/User-Profiles/Luis-Fernando-Molina.json b/Projects/Governance/Plugins/User-Profiles/Luis-Fernando-Molina.json index a5e8f2420..aa4884ea0 100644 --- a/Projects/Governance/Plugins/User-Profiles/Luis-Fernando-Molina.json +++ b/Projects/Governance/Plugins/User-Profiles/Luis-Fernando-Molina.json @@ -1,6 +1,6 @@ { "type": "User Profile", - "name": "Luis-Fernando-MolinaXX", + "name": "Luis-Fernando-Molina", "config": "{\"tokens\":10000000,\"signature\":{\"message\":\"Luis-Fernando-Molina\",\"messageHash\":\"0x443abf3389e332a62d21b84dd12e271cb428d334195d3aeb986ca85ee53cccb9\",\"v\":\"0x1b\",\"r\":\"0x90293b042c180aa21b05f0356f31688c597be4ff2df136f63a2b8a899c658eb0\",\"s\":\"0x42abf909024d34217430e42ebadc96b7834218cc86a4c295a2ae419ff2fca6e3\",\"signature\":\"0x90293b042c180aa21b05f0356f31688c597be4ff2df136f63a2b8a899c658eb042abf909024d34217430e42ebadc96b7834218cc86a4c295a2ae419ff2fca6e31b\"},\"codeName\":\"Luis-Fernando-Molina\"}", "project": "Governance", "tokenPowerSwitch": { @@ -565,7 +565,7 @@ "featureClaimVotes": [ { "type": "Feature Claim Vote", - "name": "Luis-Fernando-Molina Governance System New Features", + "name": "Luis-Fernando-MolinaXX Governance System New Features", "config": "{}", "project": "Governance", "id": "4381f059-44c8-4843-9cac-8a7cf41fa14c", @@ -596,7 +596,7 @@ }, "referenceParentCombinedNodePath": [ [ - "Luis-Fernando-MolinaXX", + "Luis-Fernando-Molina", "User Profile", "Governance", "148911b3-b2f3-44fb-8cb4-017991789132" @@ -648,7 +648,7 @@ }, { "type": "Feature Claim Vote", - "name": "Luis-Fernando-Molina API Maps New Features", + "name": "Luis-Fernando-MolinaXX API Maps New Features", "config": "{}", "project": "Governance", "id": "6145983d-799e-4a3e-ac04-ed29b398cdce", @@ -679,7 +679,7 @@ }, "referenceParentCombinedNodePath": [ [ - "Luis-Fernando-MolinaXX", + "Luis-Fernando-Molina", "User Profile", "Governance", "148911b3-b2f3-44fb-8cb4-017991789132" diff --git a/Projects/ProjectsSchema.json b/Projects/ProjectsSchema.json index 2b289b65d..15d0d56ba 100644 --- a/Projects/ProjectsSchema.json +++ b/Projects/ProjectsSchema.json @@ -874,10 +874,16 @@ "CL": { "utilities": [ { - "name": "Async Function", + "name": "Async Functions", "propertyName": "asyncFunctions", "functionName": "newFoundationsUtilitiesAsyncFunctions", "fileName": "AsyncFunctions.js" + }, + { + "name": "Web Access", + "propertyName": "webAccess", + "functionName": "newFoundationsUtilitiesWebAccess", + "fileName": "WebAccess.js" } ] },