mirror of
https://github.com/modelcontextprotocol/servers.git
synced 2026-04-18 04:54:05 +02:00
fix: resolve typescript errors and add buildUrl utility
- Fix headers type assertion issue - Add buildUrl utility function for URL parameter handling
This commit is contained in:
@@ -14,11 +14,21 @@ async function parseResponseBody(response: Response): Promise<unknown> {
|
||||
return response.text();
|
||||
}
|
||||
|
||||
export function buildUrl(baseUrl: string, params: Record<string, string | number | undefined>): string {
|
||||
const url = new URL(baseUrl);
|
||||
Object.entries(params).forEach(([key, value]) => {
|
||||
if (value !== undefined) {
|
||||
url.searchParams.append(key, value.toString());
|
||||
}
|
||||
});
|
||||
return url.toString();
|
||||
}
|
||||
|
||||
export async function githubRequest(
|
||||
url: string,
|
||||
options: RequestOptions = {}
|
||||
): Promise<unknown> {
|
||||
const headers = {
|
||||
const headers: Record<string, string> = {
|
||||
"Accept": "application/vnd.github.v3+json",
|
||||
"Content-Type": "application/json",
|
||||
...options.headers,
|
||||
|
||||
Reference in New Issue
Block a user