gitlab-badge-proxy 0.1.1 → 0.1.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- {"version":3,"file":"app.d.ts","sourceRoot":"","sources":["../../src/app.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAgB,MAAM,MAAM,CAAC;AAC1C,OAAO,EAAc,KAAK,MAAM,EAAE,MAAM,aAAa,CAAC;AACtD,OAAO,EAAE,UAAU,EAAE,KAAK,MAAM,EAAE,MAAM,aAAa,CAAC;AAoBtD,OAAO,EACL,eAAe,EAkBhB,MAAM,YAAY,CAAC;AAuWpB,wBAAgB,SAAS,CAAC,SAAS,GAAE,MAAM,MAAmB,GAAG,IAAI,CAqNpE;AAED,OAAO,EAAE,eAAe,EAAE,CAAC;AAC3B,eAAO,MAAM,GAAG,4EAAc,CAAC"}
1
+ {"version":3,"file":"app.d.ts","sourceRoot":"","sources":["../../src/app.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAgB,MAAM,MAAM,CAAC;AAE1C,OAAO,EAAc,KAAK,MAAM,EAAE,MAAM,aAAa,CAAC;AACtD,OAAO,EAAE,UAAU,EAAE,KAAK,MAAM,EAAE,MAAM,aAAa,CAAC;AAoBtD,OAAO,EACL,eAAe,EAkBhB,MAAM,YAAY,CAAC;AAyWpB,wBAAgB,SAAS,CAAC,SAAS,GAAE,MAAM,MAAmB,GAAG,IAAI,CAyNpE;AAED,OAAO,EAAE,eAAe,EAAE,CAAC;AAC3B,eAAO,MAAM,GAAG,4EAAc,CAAC"}
package/dist/src/app.js CHANGED
@@ -1,4 +1,5 @@
1
1
  import { Hono } from "hono";
2
+ import { logger } from "hono/logger";
2
3
  import { loadConfig } from "./config.js";
3
4
  export { loadConfig } from "./config.js";
4
5
  import { getContributorsCount, getForksCount, getGoModVersion, getIssuesCount, getJobCoverage, getLabelColor, getLanguages, getLastCommitDate, getLatestPipeline, getLatestRelease, getLatestTag, getLicenseName, getMergeRequestsCount, getPipelineCoverage, getStarsCount, } from "./gitlab.js";
@@ -97,6 +98,8 @@ async function proxyGitlabApi(config, projectPath, subpath, search) {
97
98
  const upstream = `${config.gitlabUrl}/api/v4/projects/${encodeURIComponent(projectPath)}${subpath ? `/${subpath}` : ""}${search}`;
98
99
  try {
99
100
  const response = await fetch(upstream, { headers: { "PRIVATE-TOKEN": config.gitlabToken } });
101
+ // Server-side only (stdout), never echoed back to the client.
102
+ console.log(`gitlab-badge-proxy: GET ${upstream} -> ${response.status}`);
100
103
  const text = await response.text();
101
104
  const maxAge = response.ok ? config.cacheMaxAgeSeconds : 30;
102
105
  let body = text;
@@ -300,6 +303,9 @@ function registerBadgeRoute(app, getConfig, path, fallback, context, compute) {
300
303
  }
301
304
  export function createApp(getConfig = loadConfig) {
302
305
  const app = new Hono();
306
+ // Access log: one line per request in, one per response out (method, path, status, duration) —
307
+ // confirms at a glance that the proxy is receiving and resolving requests as expected.
308
+ app.use(logger());
303
309
  // Collapses accidental double slashes (e.g. a caller's `gitlab_url` ending in `/`, concatenated
304
310
  // with a path that also starts with `/`) instead of 404ing on them.
305
311
  app.use(async (c, next) => {
@@ -1 +1 @@
1
- {"version":3,"file":"gitlab.d.ts","sourceRoot":"","sources":["../../src/gitlab.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAE1C,MAAM,WAAW,eAAe;IAC9B,EAAE,EAAE,MAAM,CAAC;IACX,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,cAAc;IAC7B,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;CACjB;AAiCD,wBAAsB,iBAAiB,CACrC,MAAM,EAAE,MAAM,EACd,WAAW,EAAE,MAAM,EACnB,GAAG,EAAE,MAAM,GACV,OAAO,CAAC,eAAe,GAAG,IAAI,CAAC,CAIjC;AAED,wBAAsB,mBAAmB,CACvC,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,MAAM,EACd,WAAW,EAAE,MAAM,EACnB,KAAK,EAAE,iBAAiB,EACxB,MAAM,EAAE,MAAM,GAAG,SAAS,GACzB,OAAO,CAAC,MAAM,CAAC,CAQjB;AAED,wBAAsB,iBAAiB,CACrC,MAAM,EAAE,MAAM,EACd,WAAW,EAAE,MAAM,EACnB,GAAG,EAAE,MAAM,GAAG,SAAS,EACvB,IAAI,EAAE,MAAM,GAAG,SAAS,GACvB,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAQxB;AAED,wBAAsB,cAAc,CAAC,MAAM,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAKhG;AAED,wBAAsB,YAAY,CAAC,MAAM,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC;IAAE,IAAI,EAAE,MAAM,CAAA;CAAE,GAAG,IAAI,CAAC,CAOxG;AAED,iGAAiG;AACjG,wBAAsB,YAAY,CAAC,MAAM,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAEvG;AAED,wBAAsB,aAAa,CAAC,MAAM,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAGtG;AAID,wBAAsB,eAAe,CACnC,MAAM,EAAE,MAAM,EACd,WAAW,EAAE,MAAM,EACnB,GAAG,EAAE,MAAM,EACX,QAAQ,EAAE,MAAM,GACf,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CASxB"}
@@ -4,7 +4,16 @@ async function gitlabRequest(config, projectPath, path) {
4
4
  const response = await fetch(url, {
5
5
  headers: { "PRIVATE-TOKEN": config.gitlabToken },
6
6
  });
7
+ // Server-side only (stdout), never echoed back to the client - shows the exact upstream call this
8
+ // request triggered, for anyone watching the proxy's own logs to debug a GitLab-side issue.
9
+ console.log(`gitlab-badge-proxy: GET ${url} -> ${response.status}`);
7
10
  if (!response.ok) {
11
+ // GitLab's own error body (e.g. `{"message":"401 Unauthorized"}`) plus the token's length (never
12
+ // its value) are usually enough to tell "GITLAB_TOKEN isn't set" (length 0) apart from "it's set
13
+ // but wrong/expired/missing scope" (non-zero length, still 401/403) from the logs alone.
14
+ const body = await response.text().catch(() => "<unreadable response body>");
15
+ console.error(`gitlab-badge-proxy: GitLab API error ${response.status} for ${url} ` +
16
+ `(GITLAB_TOKEN length: ${config.gitlabToken.length}): ${body.slice(0, 300)}`);
8
17
  throw new Error(`GitLab API responded with ${response.status}`);
9
18
  }
10
19
  return response;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gitlab-badge-proxy",
3
- "version": "0.1.1",
3
+ "version": "0.1.3",
4
4
  "description": "Server-side proxy that turns private GitLab pipeline/coverage status into public SVG badges, without ever exposing the GitLab instance's URL to clients.",
5
5
  "type": "module",
6
6
  "license": "MIT",