mirror of
https://github.com/abhigyanpatwari/GitNexus.git
synced 2026-09-22 00:31:17 +00:00
fix(server): use ipKeyGenerator for IPv6-safe rate-limit key generation and remove duplicate interface method
This commit is contained in:
parent
1290973cb3
commit
e5eb9eabb4
2 changed files with 2 additions and 21 deletions
|
|
@ -346,25 +346,6 @@ export interface ScopeResolver {
|
|||
*/
|
||||
loadResolutionConfig?(repoPath: string): Promise<unknown> | 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> | unknown;
|
||||
|
||||
/**
|
||||
* Per-scope binding-merge precedence. The shared finalize pass
|
||||
* collects bindings from multiple sources (local declarations,
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue