Comparing version 1.0.12 to 1.0.13
@@ -31,6 +31,11 @@ const csvWriter = require('csv-write-stream'); | ||
}; | ||
exports.getClient = function(clientName) { | ||
return getClientFromCSVFile(clientName); | ||
return getClientFromCSVFileByNameOrId(clientName); | ||
}; | ||
exports.getListOfClients = function() { | ||
return getAllClientFromCSVFile(); | ||
}; | ||
exports.addClient = function(clientName, clientId, clientSecret, scope) { | ||
@@ -61,4 +66,3 @@ saveClientToCSVFile(clientName, clientId, clientSecret, scope); | ||
function getClientFromCSVFile(clientName) { | ||
var clientObj = {}; | ||
function getClientFromCSVFileByNameOrId(clientIdentifier) { | ||
let inputStream = fs.createReadStream(configFilePath, 'utf8'); | ||
@@ -68,11 +72,15 @@ inputStream | ||
.on('data', function (row) { | ||
console.log('A row arrived: ', row); | ||
if (row.name === clientIdentifier || row.clientId === clientIdentifier) { | ||
return JSON.stringify(createClientConfig(row)); | ||
} | ||
}) | ||
.on('end', function (data) { | ||
console.log('No more rows!'); | ||
console.log('No more data in file.'); | ||
}); | ||
console.log("Client config " + clientIdentifier + " not found."); | ||
return JSON.stringify({}); | ||
} | ||
function getAllClientFromCSVFile() { | ||
var listOfClientConfig = []; | ||
let listOfClientConfig = []; | ||
let inputStream = fs.createReadStream(configFilePath, 'utf8'); | ||
@@ -82,8 +90,16 @@ inputStream | ||
.on('data', function (row) { | ||
console.log('A row arrived: ', row); | ||
listOfClientConfig.push(createClientConfig(row)); | ||
}) | ||
.on('end', function (data) { | ||
console.log('No more rows!'); | ||
console.log('No more data in file.'); | ||
}); | ||
return JSON.stringify(listOfClientConfig); | ||
} | ||
function createClientConfig(rowElement) { | ||
return new ClientConfig( | ||
rowElement.name, | ||
rowElement.clientId, | ||
rowElement.clientSecret, | ||
rowElement.scope) | ||
} |
{ | ||
"name": "coaclient", | ||
"version": "1.0.12", | ||
"version": "1.0.13", | ||
"description": "Custom Node.js library for manage CourseraOAuth2 API tokens", | ||
@@ -5,0 +5,0 @@ "main": "coaclient", |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
16127
88