diff --git a/package-lock.json b/package-lock.json
index 65732e0..5b63eef 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -9,7 +9,7 @@
"version": "1.0.1",
"license": "GPL-3.0-only",
"dependencies": {
- "axios": "^1.6.7"
+ "axios": "^1.11.0"
},
"devDependencies": {
"@babel/core": "^7.28.0",
@@ -3100,13 +3100,13 @@
"license": "MIT"
},
"node_modules/axios": {
- "version": "1.10.0",
- "resolved": "https://registry.npmjs.org/axios/-/axios-1.10.0.tgz",
- "integrity": "sha512-/1xYAC4MP/HEG+3duIhFr4ZQXR4sQXOIe+o6sdqzeykGLx6Upp/1p8MHqhINOvGeP7xyNHe7tsiJByc4SSVUxw==",
+ "version": "1.11.0",
+ "resolved": "https://registry.npmjs.org/axios/-/axios-1.11.0.tgz",
+ "integrity": "sha512-1Lx3WLFQWm3ooKDYZD1eXmoGO9fxYQjrycfHFC8P0sCfQVXyROp0p9PFWBehewBOdCwHc+f/b8I0fMto5eSfwA==",
"license": "MIT",
"dependencies": {
"follow-redirects": "^1.15.6",
- "form-data": "^4.0.0",
+ "form-data": "^4.0.4",
"proxy-from-env": "^1.1.0"
}
},
diff --git a/package.json b/package.json
index b52673b..c0b603d 100644
--- a/package.json
+++ b/package.json
@@ -29,7 +29,7 @@
"access": "public"
},
"dependencies": {
- "axios": "^1.6.7"
+ "axios": "^1.11.0"
},
"devDependencies": {
"@babel/core": "^7.28.0",
diff --git a/src/core/BaseAPIHelper.js b/src/core/BaseAPIHelper.js
new file mode 100644
index 0000000..1576131
--- /dev/null
+++ b/src/core/BaseAPIHelper.js
@@ -0,0 +1,65 @@
+/**
+ * Classe base para API Helpers
+ */
+export class BaseAPIHelper {
+ constructor(config) {
+ if (!config || !config.username) {
+ throw new Error('Nome de usuário é obrigatório');
+ }
+
+ this.config = {
+ username: config.username,
+ token: config.token || null,
+ baseUrl: config.baseUrl || null
+ };
+
+ // Serviços que serão implementados
+ this.userService = null;
+ this.repoService = null;
+ this.activityService = null;
+ this.languageService = null;
+ this.commitService = null;
+ this.contributionService = null;
+
+ // Estado atual
+ this.currentRepo = null;
+ this.currentPath = '';
+ this.currentCommit = null;
+ }
+
+ async loadAllData() {
+ throw new Error('Método loadAllData() deve ser implementado');
+ }
+
+ // Getters
+ get userData() { return this.userService?.userData; }
+ get reposData() { return this.repoService?.reposData; }
+ get activitiesData() { return this.activityService?.activitiesData; }
+ get languagesData() { return this.languageService?.languagesData; }
+ get commitsData() { return this.commitService?.commitsData; }
+ get contributionsData() { return this.contributionService?.contributionsData; }
+
+ // Métodos de renderização
+ renderProfile() { return this.userService?.renderProfile(); }
+ renderActivities() { return this.activityService?.renderActivities(); }
+ renderRepos(sort) { return this.repoService?.renderRepos(sort); }
+
+ renderCharts() {
+ return {
+ languages: {
+ labels: Object.keys(this.languagesData || {}),
+ data: Object.values(this.languagesData || {})
+ },
+ commits: {
+ labels: Object.keys(this.commitsData || {}).slice(0, 10),
+ data: Object.values(this.commitsData || {}).slice(0, 10)
+ },
+ contributions: {
+ labels: Object.keys(this.contributionsData || {}),
+ data: Object.values(this.contributionsData || {})
+ }
+ };
+ }
+}
+
+export default BaseAPIHelper;
\ No newline at end of file
diff --git a/src/core/GitHubAPIHelper.js b/src/core/GitHubAPIHelper.js
index 4c2a133..8ecd6f4 100644
--- a/src/core/GitHubAPIHelper.js
+++ b/src/core/GitHubAPIHelper.js
@@ -1,70 +1,32 @@
-/**
- * @license
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- */
-
-import UserService from '../services/UserService.js';
-import RepoService from '../services/RepoService.js';
-import ActivityService from '../services/ActivityService.js';
-import LanguageService from '../services/LanguageService.js';
-import CommitService from '../services/CommitService.js';
-import ContributionService from '../services/ContributionService.js';
-/**
- * GitHubAPIHelper - Main facade class for GitHub API operations
- *
- * Provides a unified interface to access GitHub user data, repositories,
- * activities, languages, commits and contributions through specialized services.
- * Implements the Facade design pattern to simplify complex API interactions.
- */
-class GitHubAPIHelper {
- /**
- * Constructs a new GitHubAPIHelper instance
- * @param {Object} config Configuration object
- * @param {string} config.githubUsername GitHub username (required)
- * @param {string} [config.githubToken] GitHub personal access token (optional)
- * @throws {Error} When githubUsername is not provided
- */
+import BaseAPIHelper from './BaseAPIHelper.js';
+import GitHubUserService from '../services/github/UserService.js';
+import GitHubRepoService from '../services/github/RepoService.js';
+import GitHubActivityService from '../services/github/ActivityService.js';
+import GitHubLanguageService from '../services/github/LanguageService.js';
+import GitHubCommitService from '../services/github/CommitService.js';
+import GitHubContributionService from '../services/github/ContributionService.js';
+
+class GitHubAPIHelper extends BaseAPIHelper {
constructor(config) {
- if (!config || !config.githubUsername) {
- throw new Error('GitHub username is required');
- }
-
- this.config = {
- githubUsername: config.githubUsername,
- githubToken: config.githubToken || null
+ super({
+ username: config.username,
+ token: config.token
+ });
+
+ // Mapeia para os campos esperados pelos serviços internos
+ const serviceConfig = {
+ githubUsername: config.username,
+ githubToken: config.token
};
- // Initialize specialized services
- this.userService = new UserService(this.config);
- this.repoService = new RepoService(this.config);
- this.activityService = new ActivityService(this.config);
- this.languageService = new LanguageService(this.config);
- this.commitService = new CommitService(this.config);
- this.contributionService = new ContributionService(this.config);
-
- // Current state tracking
- this.currentRepo = null;
- this.currentPath = '';
- this.currentCommit = null;
+ this.userService = new GitHubUserService(serviceConfig);
+ this.repoService = new GitHubRepoService(serviceConfig);
+ this.activityService = new GitHubActivityService(serviceConfig);
+ this.languageService = new GitHubLanguageService(serviceConfig);
+ this.commitService = new GitHubCommitService(serviceConfig);
+ this.contributionService = new GitHubContributionService(serviceConfig);
}
- /**
- * Loads all available GitHub data for the user
- * @async
- * @returns {Promise} True if all data loaded successfully
- * @throws {Error} If any data loading fails
- */
async loadAllData() {
try {
await this.userService.loadUserData();
@@ -75,140 +37,10 @@ class GitHubAPIHelper {
await this.contributionService.loadContributionsData();
return true;
} catch (err) {
- console.error('Error loading data:', err);
+ console.error('Erro ao carregar dados do GitHub:', err);
throw err;
}
}
-
- /* Data Accessors */
-
- /**
- * Gets user profile data
- * @returns {Object} User profile information
- */
- get userData() { return this.userService.userData; }
-
- /**
- * Gets repositories data
- * @returns {Array