mirror of
https://github.com/modelcontextprotocol/servers.git
synced 2026-04-21 21:35:15 +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();
|
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(
|
export async function githubRequest(
|
||||||
url: string,
|
url: string,
|
||||||
options: RequestOptions = {}
|
options: RequestOptions = {}
|
||||||
): Promise<unknown> {
|
): Promise<unknown> {
|
||||||
const headers = {
|
const headers: Record<string, string> = {
|
||||||
"Accept": "application/vnd.github.v3+json",
|
"Accept": "application/vnd.github.v3+json",
|
||||||
"Content-Type": "application/json",
|
"Content-Type": "application/json",
|
||||||
...options.headers,
|
...options.headers,
|
||||||
|
|||||||
Reference in New Issue
Block a user