Skip to content

Commit

Permalink
#1 Removed redundant API key handler.
Browse files Browse the repository at this point in the history
  • Loading branch information
JamesDonnelly committed Jun 8, 2019
1 parent 6133743 commit db9e01b
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 12 deletions.
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
node_modules
.DS_Store
xivapi-key.txt
data/cached/*.json
9 changes: 1 addition & 8 deletions src/APICrawler.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ const Progress = require('cli-progress');
const urls = require('./xivapi/urls');

module.exports = class APICrawler {
constructor(config = {}, apiKey = '') {
constructor(config = {}) {
if (!config || typeof config !== 'object') {
throw new Error('Config passed to APICrawler as first argument must be an object.');
}
Expand All @@ -15,12 +15,7 @@ module.exports = class APICrawler {
);
}

if (!apiKey || typeof apiKey !== 'string') {
throw new Error('API key passed to APICrawler as second argument must be a string.');
}

this.apiCallCount = 0;
this.apiKey = apiKey;
this.config = config;
this.cumulativeSuccessfulCalls = 0;
this.errors = 0;
Expand Down Expand Up @@ -79,7 +74,6 @@ module.exports = class APICrawler {
const apiPath = urls[`${name.charAt(0).toLowerCase()}${name.substr(1)}`]();

const queryStringParts = [
`apiKey=${this.apiKey}`,
`limit=${limit}`
];

Expand Down Expand Up @@ -247,7 +241,6 @@ module.exports = class APICrawler {
const apiPath = urls.search();

const queryStringParts = [
`apiKey=${this.apiKey}`,
`page=${page === -1 ? 1 : page}`
];

Expand Down
5 changes: 2 additions & 3 deletions src/update.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ const listAPI = require('./parsers/listAPI');

class API {
async crawl(config) {
return await new APICrawler(config, this.apiKey)[config.method]();
return await new APICrawler(config)[config.method]();
}

async init(optionsIn) {
Expand Down Expand Up @@ -59,8 +59,7 @@ class API {
console.info(`Valid options include: '${validOptions.join('\', \'')}'`);
return;
}

this.apiKey = await fs.readFileSync('./xivapi-key.txt', 'utf-8');

this.options = options;
}

Expand Down

0 comments on commit db9e01b

Please sign in to comment.