From e5eb9eabb495f6df1a065d6b0b0de98d4b60b36a Mon Sep 17 00:00:00 2001 From: Sparsh Date: Tue, 5 May 2026 21:53:19 +0530 Subject: [PATCH] fix(server): use ipKeyGenerator for IPv6-safe rate-limit key generation and remove duplicate interface method --- .../contract/scope-resolver.ts | 19 ------------------- gitnexus/src/server/validation.ts | 4 ++-- 2 files changed, 2 insertions(+), 21 deletions(-) diff --git a/gitnexus/src/core/ingestion/scope-resolution/contract/scope-resolver.ts b/gitnexus/src/core/ingestion/scope-resolution/contract/scope-resolver.ts index b3312d4e8..6cd9a3d78 100644 --- a/gitnexus/src/core/ingestion/scope-resolution/contract/scope-resolver.ts +++ b/gitnexus/src/core/ingestion/scope-resolution/contract/scope-resolver.ts @@ -346,25 +346,6 @@ export interface ScopeResolver { */ loadResolutionConfig?(repoPath: string): Promise | unknown; - /** - * Optional one-shot loader for cross-file import-resolution config - * (e.g. tsconfig path aliases for TypeScript, go.mod paths for Go, - * composer.json autoload for PHP). The orchestrator calls this once - * per workspace pass with the repo root and threads the result into - * every subsequent `resolveImportTarget` call as the - * `resolutionConfig` parameter. - * - * Languages that don't need any per-workspace config leave this - * undefined; the orchestrator threads `undefined` to - * `resolveImportTarget` in that case. Returning `null` is also - * supported and equivalent to "no config available". - * - * May be sync or async — the orchestrator awaits the result. The - * shape is opaque to the orchestrator (`unknown`); the per-language - * `resolveImportTarget` casts it to the language's expected shape. - */ - loadResolutionConfig?(repoPath: string): Promise | unknown; - /** * Per-scope binding-merge precedence. The shared finalize pass * collects bindings from multiple sources (local declarations, diff --git a/gitnexus/src/server/validation.ts b/gitnexus/src/server/validation.ts index 54bf73d4f..83fa6922a 100644 --- a/gitnexus/src/server/validation.ts +++ b/gitnexus/src/server/validation.ts @@ -19,7 +19,7 @@ */ import path from 'node:path'; -import rateLimit, { type RateLimitRequestHandler } from 'express-rate-limit'; +import rateLimit, { ipKeyGenerator, type RateLimitRequestHandler } from 'express-rate-limit'; import type { Request } from 'express'; /** @@ -151,7 +151,7 @@ export function createRouteLimiter(opts?: RouteLimiterOverrides): RateLimitReque standardHeaders: 'draft-7', legacyHeaders: false, passOnStoreError: true, - keyGenerator: (req: Request) => req.ip ?? req.socket?.remoteAddress ?? 'unknown', + keyGenerator: (req: Request) => ipKeyGenerator(req.ip ?? req.socket?.remoteAddress ?? ''), message: { error: 'Too many requests, please try again later.' }, ...opts, });