From 6da11e624b0d7152dbc19fa8f948c827d92b7fd8 Mon Sep 17 00:00:00 2001 From: jNullj <15849761+jNullj@users.noreply.github.com> Date: Mon, 14 Sep 2026 20:18:23 +0300 Subject: [PATCH] refactor [Github JsDelivr NpmDownloads NpmStatDownloads GitlabIssues] to use `routeEnum` & add hacktoberfest 2026 (#12166) * refactor: use routeEnum at Github services & add hacktoberfest 2026 * refactor: use routeEnum at JsDelivr services * refactor: use routeEnum at NpmDownloads * refactor: use routeEnum at NpmStatDownloads service * refactor: use routeEnum at GitlabIssues --- services/github/github-commit-activity.service.js | 3 ++- services/github/github-contributors.service.js | 4 +++- services/github/github-downloads.service.js | 4 +++- services/github/github-hacktoberfest.service.js | 7 ++++++- services/github/github-milestone.service.js | 4 +++- services/github/github-release-date.service.js | 4 +++- services/gitlab/gitlab-issues.service.js | 11 ++++++++++- services/jsdelivr/jsdelivr-hits-github.service.js | 3 ++- services/jsdelivr/jsdelivr-hits-npm.service.js | 3 ++- services/npm-stat/npm-stat-downloads.service.js | 3 ++- services/npm/npm-downloads.service.js | 3 ++- 11 files changed, 38 insertions(+), 11 deletions(-) diff --git a/services/github/github-commit-activity.service.js b/services/github/github-commit-activity.service.js index f1504f3638..92e396e416 100644 --- a/services/github/github-commit-activity.service.js +++ b/services/github/github-commit-activity.service.js @@ -31,9 +31,10 @@ export default class GitHubCommitActivity extends GithubAuthV4Service { static category = 'activity' static route = { base: 'github/commit-activity', - pattern: ':interval(t|y|m|4w|w)/:user/:repo/:branch*', + pattern: ':interval/:user/:repo/:branch*', queryParamSchema, } + static routeEnum = ['t', 'y', 'm', '4w', 'w'] static openApi = { '/github/commit-activity/{interval}/{user}/{repo}': { diff --git a/services/github/github-contributors.service.js b/services/github/github-contributors.service.js index 991232d486..c9acc9b331 100644 --- a/services/github/github-contributors.service.js +++ b/services/github/github-contributors.service.js @@ -19,9 +19,11 @@ export default class GithubContributors extends GithubAuthV3Service { base: 'github', // note we call this param 'metric' instead of 'variant' because of // https://github.com/badges/shields/issues/10323 - pattern: ':metric(contributors|contributors-anon)/:user/:repo', + pattern: ':metric/:user/:repo', } + static routeEnum = ['contributors', 'contributors-anon'] + static openApi = { '/github/{metric}/{user}/{repo}': { get: { diff --git a/services/github/github-downloads.service.js b/services/github/github-downloads.service.js index 4b853358c0..97f7bf9d05 100644 --- a/services/github/github-downloads.service.js +++ b/services/github/github-downloads.service.js @@ -59,10 +59,12 @@ export default class GithubDownloads extends GithubAuthV3Service { static category = 'downloads' static route = { base: 'github', - pattern: ':variant(downloads|downloads-pre)/:user/:repo/:tag*/:assetName', + pattern: ':variant/:user/:repo/:tag*/:assetName', queryParamSchema, } + static routeEnum = ['downloads', 'downloads-pre'] + static openApi = { '/github/downloads/{user}/{repo}/total': { get: { diff --git a/services/github/github-hacktoberfest.service.js b/services/github/github-hacktoberfest.service.js index a5766aab67..902e5b34fb 100644 --- a/services/github/github-hacktoberfest.service.js +++ b/services/github/github-hacktoberfest.service.js @@ -53,10 +53,15 @@ export default class GithubHacktoberfestCombinedStatus extends GithubAuthV4Servi static category = 'issue-tracking' static route = { base: 'github/hacktoberfest', - pattern: ':year(2019|2020|2021|2022|2023|2024|2025)/:user/:repo', + pattern: ':year/:user/:repo', queryParamSchema, } + static routeEnum = Array.from( + { length: 2026 - 2019 + 1 }, + (_, i) => `${2019 + i}`, + ) + static openApi = { '/github/hacktoberfest/{year}/{user}/{repo}': { get: { diff --git a/services/github/github-milestone.service.js b/services/github/github-milestone.service.js index f7874ecbd1..b82b25955f 100644 --- a/services/github/github-milestone.service.js +++ b/services/github/github-milestone.service.js @@ -16,9 +16,11 @@ export default class GithubMilestone extends GithubAuthV3Service { static category = 'issue-tracking' static route = { base: 'github/milestones', - pattern: ':variant(open|closed|all)/:user/:repo', + pattern: ':variant/:user/:repo', } + static routeEnum = ['open', 'closed', 'all'] + static openApi = { '/github/milestones/{variant}/{user}/{repo}': { get: { diff --git a/services/github/github-release-date.service.js b/services/github/github-release-date.service.js index 4d61429843..f53e65eab2 100644 --- a/services/github/github-release-date.service.js +++ b/services/github/github-release-date.service.js @@ -31,10 +31,12 @@ export default class GithubReleaseDate extends GithubAuthV3Service { static category = 'activity' static route = { base: 'github', - pattern: ':variant(release-date|release-date-pre)/:user/:repo', + pattern: ':variant/:user/:repo', queryParamSchema, } + static routeEnum = ['release-date', 'release-date-pre'] + static openApi = { '/github/{variant}/{user}/{repo}': { get: { diff --git a/services/gitlab/gitlab-issues.service.js b/services/gitlab/gitlab-issues.service.js index 2c5c65bf84..e2239e4afe 100644 --- a/services/gitlab/gitlab-issues.service.js +++ b/services/gitlab/gitlab-issues.service.js @@ -25,10 +25,19 @@ export default class GitlabIssues extends GitLabBase { static route = { base: 'gitlab/issues', - pattern: ':variant(all|all-raw|open|open-raw|closed|closed-raw)/:project+', + pattern: ':variant/:project+', queryParamSchema, } + static routeEnum = [ + 'all', + 'all-raw', + 'open', + 'open-raw', + 'closed', + 'closed-raw', + ] + static openApi = { '/gitlab/issues/{variant}/{project}': { get: { diff --git a/services/jsdelivr/jsdelivr-hits-github.service.js b/services/jsdelivr/jsdelivr-hits-github.service.js index 0575492487..5aa1ecc9a0 100644 --- a/services/jsdelivr/jsdelivr-hits-github.service.js +++ b/services/jsdelivr/jsdelivr-hits-github.service.js @@ -4,8 +4,9 @@ import { schema, periodMap, BaseJsDelivrService } from './jsdelivr-base.js' export default class JsDelivrHitsGitHub extends BaseJsDelivrService { static route = { base: 'jsdelivr/gh', - pattern: ':period(hd|hw|hm|hy)/:user/:repo', + pattern: ':period/:user/:repo', } + static routeEnum = ['hd', 'hw', 'hm', 'hy'] static openApi = { '/jsdelivr/gh/{period}/{user}/{repo}': { diff --git a/services/jsdelivr/jsdelivr-hits-npm.service.js b/services/jsdelivr/jsdelivr-hits-npm.service.js index 86f5383229..37b8f8ad1d 100644 --- a/services/jsdelivr/jsdelivr-hits-npm.service.js +++ b/services/jsdelivr/jsdelivr-hits-npm.service.js @@ -4,8 +4,9 @@ import { schema, periodMap, BaseJsDelivrService } from './jsdelivr-base.js' export default class JsDelivrHitsNPM extends BaseJsDelivrService { static route = { base: 'jsdelivr/npm', - pattern: ':period(hd|hw|hm|hy)/:scope(@[^/]+)?/:packageName', + pattern: ':period/:scope(@[^/]+)?/:packageName', } + static routeEnum = ['hd', 'hw', 'hm', 'hy'] static openApi = { '/jsdelivr/npm/{period}/{packageName}': { diff --git a/services/npm-stat/npm-stat-downloads.service.js b/services/npm-stat/npm-stat-downloads.service.js index d06a28ef3d..6aecf3c431 100644 --- a/services/npm-stat/npm-stat-downloads.service.js +++ b/services/npm-stat/npm-stat-downloads.service.js @@ -19,8 +19,9 @@ export default class NpmStatDownloads extends BaseJsonService { static route = { base: 'npm-stat', - pattern: ':interval(dw|dm|dy)/:author', + pattern: ':interval/:author', } + static routeEnum = ['dw', 'dm', 'dy'] static openApi = { '/npm-stat/{interval}/{author}': { diff --git a/services/npm/npm-downloads.service.js b/services/npm/npm-downloads.service.js index 67a42c8711..377abbfac1 100644 --- a/services/npm/npm-downloads.service.js +++ b/services/npm/npm-downloads.service.js @@ -48,8 +48,9 @@ export default class NpmDownloads extends BaseJsonService { static route = { base: 'npm', - pattern: ':interval(dw|dm|dy|d18m)/:scope(@.+)?/:packageName', + pattern: ':interval/:scope(@.+)?/:packageName', } + static routeEnum = ['dw', 'dm', 'dy', 'd18m'] static openApi = { '/npm/{interval}/{packageName}': {