From b2b946d36b48f535ec56516cf273e17c734b83f9 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Thu, 22 Jan 2026 06:20:45 +0000 Subject: [PATCH 1/7] Initial plan From 98e774144a74930416da5d29acbb6b05b7ae1761 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Thu, 22 Jan 2026 06:25:41 +0000 Subject: [PATCH 2/7] Fix form issues: remove duplicate action, add accessibility, improve validation Co-authored-by: wildan3105 <7030099+wildan3105@users.noreply.github.com> --- public/js/form-validation.js | 20 ++++++++++++++++++++ src/pages/partials/body.handlebars | 19 ++++--------------- 2 files changed, 24 insertions(+), 15 deletions(-) create mode 100644 public/js/form-validation.js diff --git a/public/js/form-validation.js b/public/js/form-validation.js new file mode 100644 index 00000000..b6f86783 --- /dev/null +++ b/public/js/form-validation.js @@ -0,0 +1,20 @@ +/* eslint-disable no-undef */ + +// Form validation for GitHub username search +document.getElementById('search-form').onsubmit = function() { + const inputField = document.getElementById('username'); + const username = inputField.value.trim(); + + if (username === '') { + alert('Username cannot be empty or contain only spaces.'); + return false; // Prevent form submission + } + + if (/\s/.test(inputField.value)) { + alert('Username cannot contain any spaces.'); + return false; + } + + showLoader(); + return true; // Allow form submission +}; diff --git a/src/pages/partials/body.handlebars b/src/pages/partials/body.handlebars index 004186c3..daa35ad7 100644 --- a/src/pages/partials/body.handlebars +++ b/src/pages/partials/body.handlebars @@ -10,11 +10,11 @@
-
+
- -
@@ -101,17 +101,6 @@ +
- - From 80fee51924367c3ad071e5f18a6cdac9567e54e8 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Thu, 22 Jan 2026 06:27:02 +0000 Subject: [PATCH 3/7] Address code review: use consistent validation and specific eslint comment Co-authored-by: wildan3105 <7030099+wildan3105@users.noreply.github.com> --- public/js/form-validation.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/public/js/form-validation.js b/public/js/form-validation.js index b6f86783..d303c82e 100644 --- a/public/js/form-validation.js +++ b/public/js/form-validation.js @@ -1,4 +1,4 @@ -/* eslint-disable no-undef */ +/* global showLoader */ // Form validation for GitHub username search document.getElementById('search-form').onsubmit = function() { @@ -10,7 +10,7 @@ document.getElementById('search-form').onsubmit = function() { return false; // Prevent form submission } - if (/\s/.test(inputField.value)) { + if (/\s/.test(username)) { alert('Username cannot contain any spaces.'); return false; } From 440f092e8dd06c15db544599188db5757efdd84b Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Thu, 22 Jan 2026 06:28:32 +0000 Subject: [PATCH 4/7] Fix validation logic: check original value for spaces per code review Co-authored-by: wildan3105 <7030099+wildan3105@users.noreply.github.com> --- public/js/form-validation.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/public/js/form-validation.js b/public/js/form-validation.js index d303c82e..a55da2e3 100644 --- a/public/js/form-validation.js +++ b/public/js/form-validation.js @@ -10,7 +10,7 @@ document.getElementById('search-form').onsubmit = function() { return false; // Prevent form submission } - if (/\s/.test(username)) { + if (/\s/.test(inputField.value)) { alert('Username cannot contain any spaces.'); return false; } From 7613cb92327a7782432b194d2f4e00fb7b1bd4da Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Thu, 22 Jan 2026 06:42:24 +0000 Subject: [PATCH 5/7] Auto-remove spaces from username instead of showing error Co-authored-by: wildan3105 <7030099+wildan3105@users.noreply.github.com> --- public/js/form-validation.js | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/public/js/form-validation.js b/public/js/form-validation.js index a55da2e3..9df36e6e 100644 --- a/public/js/form-validation.js +++ b/public/js/form-validation.js @@ -3,17 +3,16 @@ // Form validation for GitHub username search document.getElementById('search-form').onsubmit = function() { const inputField = document.getElementById('username'); - const username = inputField.value.trim(); + // Auto-remove all spaces from the username + const username = inputField.value.replace(/\s/g, ''); if (username === '') { - alert('Username cannot be empty or contain only spaces.'); + alert('Username cannot be empty.'); return false; // Prevent form submission } - if (/\s/.test(inputField.value)) { - alert('Username cannot contain any spaces.'); - return false; - } + // Update the input field with the cleaned value + inputField.value = username; showLoader(); return true; // Allow form submission From 638e76808a7101a59a02508fedad51e309afef23 Mon Sep 17 00:00:00 2001 From: TS Wildan Syahrun Nahar | CLSD Date: Sun, 25 Jan 2026 12:34:26 +0900 Subject: [PATCH 6/7] chore: update strategy to run the project locally --- README.md | 13 ++++++------- package.json | 3 ++- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index 437ffa48..db4ee800 100644 --- a/README.md +++ b/README.md @@ -29,22 +29,21 @@ So people and/or organization can see the stats of programming language being us ### Supported environment: * Prerequisite: ```bash -Node >= v18.18.0 -NPM >= 9.5.0 +Node >= 20.6.0+ (to enable .env support) +NPM >= 9.8.1 ``` * [Generate access token (classic)](https://github.com/settings/tokens/new) with `repo` scope to ensure you don't get rate limited API call. -* Define environment variable with the following values: +* Copy `.env.example` to `.env` and fill in the required environment variables: ``` -TOKEN=your-access-token ENV=local +TOKEN=your_github_access_token_here +PORT=3000 ``` -An example of environment variable is provided [here](.env.example) - * Install dependency: `npm install` -* Start the app ` npm run start` and go to `http://localhost:3000` +* Start the app `npm run start:local` and go to `http://localhost:3000` ## Running with hot-reload ```bash diff --git a/package.json b/package.json index 396d9a1c..2133a617 100644 --- a/package.json +++ b/package.json @@ -4,12 +4,13 @@ "type": "module", "description": "show programming language based on the repos of github's account", "engines": { - "node": "18.18.0", + "node": "20.6.0", "npm": "9.5.0" }, "main": "index.js", "scripts": { "start": "node src/api/app.js | gulp", + "start:local": "node --env-file=.env src/api/app.js | gulp", "dev": "concurrently \"node src/api/app.js\" \"gulp watch\"", "lint": "eslint '**/*.js' --ignore-pattern src/utils/*.js", "lint:fix": "eslint --fix '**/*.js' --ignore-pattern node_modules/", From fce7a2db7a8389ef040d17e252bb3c0f05143073 Mon Sep 17 00:00:00 2001 From: TS Wildan Syahrun Nahar | CLSD Date: Sun, 25 Jan 2026 12:36:31 +0900 Subject: [PATCH 7/7] fix: revert irrelevant changes --- public/js/form-validation.js | 19 ------------------- src/pages/partials/body.handlebars | 19 +++++++++++++++---- 2 files changed, 15 insertions(+), 23 deletions(-) delete mode 100644 public/js/form-validation.js diff --git a/public/js/form-validation.js b/public/js/form-validation.js deleted file mode 100644 index 9df36e6e..00000000 --- a/public/js/form-validation.js +++ /dev/null @@ -1,19 +0,0 @@ -/* global showLoader */ - -// Form validation for GitHub username search -document.getElementById('search-form').onsubmit = function() { - const inputField = document.getElementById('username'); - // Auto-remove all spaces from the username - const username = inputField.value.replace(/\s/g, ''); - - if (username === '') { - alert('Username cannot be empty.'); - return false; // Prevent form submission - } - - // Update the input field with the cleaned value - inputField.value = username; - - showLoader(); - return true; // Allow form submission -}; diff --git a/src/pages/partials/body.handlebars b/src/pages/partials/body.handlebars index daa35ad7..6669775c 100644 --- a/src/pages/partials/body.handlebars +++ b/src/pages/partials/body.handlebars @@ -10,11 +10,11 @@
- +
- -
@@ -101,6 +101,17 @@ -
+ + \ No newline at end of file