mirror of
https://github.com/sourcebot-dev/sourcebot.git
synced 2025-12-11 20:05:25 +00:00
34 lines
No EOL
627 B
TypeScript
34 lines
No EOL
627 B
TypeScript
import { env } from "@/env.mjs";
|
|
|
|
interface ZoektRequest {
|
|
path: string,
|
|
body: string,
|
|
method: string,
|
|
header?: Record<string, string>,
|
|
cache?: RequestCache,
|
|
}
|
|
|
|
export const zoektFetch = async ({
|
|
path,
|
|
body,
|
|
method,
|
|
header,
|
|
cache,
|
|
}: ZoektRequest) => {
|
|
const response = await fetch(
|
|
new URL(path, env.ZOEKT_WEBSERVER_URL),
|
|
{
|
|
method,
|
|
headers: {
|
|
...header,
|
|
"Content-Type": "application/json",
|
|
},
|
|
body,
|
|
cache,
|
|
}
|
|
);
|
|
|
|
// @todo : add metrics
|
|
|
|
return response;
|
|
} |