chore: remove dead code and fix HTTP port-conflict startup (#351)
* chore: remove dead code and fix HTTP port-conflict startup - drop unused helpers, constants, schemas, and duplicated types - exit non-zero when the HTTP port is already in use - add stdio and port-conflict tests - clean dist on build, add serve:http, fix inspector:http for Inspector v2 * test: harden port-conflict test; drop unreachable listen guard - pin the child's host so BRAVE_MCP_HOST cannot bypass the conflict - bound the exit wait and reject spawn errors - remove the address() guard; 'listening' does not fire on a failed bind
This commit is contained in:
1 parent
2cf96460c1
commit
50cb919200
21 files changed
+191
-252
No files matched your search
+1
-23
@@ -1,32 +1,10 @@
|
||||
import { readFileSync } from 'node:fs';
|
||||
import { RATE_LIMIT } from './constants.js';
|
||||
|
||||
let requestCount = {
|
||||
second: 0,
|
||||
month: 0,
|
||||
lastReset: Date.now(),
|
||||
};
|
||||
|
||||
export function checkRateLimit() {
|
||||
const now = Date.now();
|
||||
if (now - requestCount.lastReset > 1000) {
|
||||
requestCount.second = 0;
|
||||
requestCount.lastReset = now;
|
||||
}
|
||||
if (requestCount.second >= RATE_LIMIT.perSecond || requestCount.month >= RATE_LIMIT.perMonth) {
|
||||
throw new Error('Rate limit exceeded');
|
||||
}
|
||||
requestCount.second++;
|
||||
requestCount.month++;
|
||||
}
|
||||
|
||||
export function stringify(data: any, pretty = false) {
|
||||
return pretty ? JSON.stringify(data, null, 2) : JSON.stringify(data);
|
||||
}
|
||||
|
||||
export type ReadBraveApiKeyFromFileResult =
|
||||
| { ok: true; key: string }
|
||||
| { ok: false; error: string };
|
||||
type ReadBraveApiKeyFromFileResult = { ok: true; key: string } | { ok: false; error: string };
|
||||
|
||||
export function readBraveApiKeyFromFile(filePath: string): ReadBraveApiKeyFromFileResult {
|
||||
try {
|
||||
|
||||
Reference in new issue
Block a user