mirror of
https://github.com/karakeep-app/karakeep.git
synced 2026-02-28 18:25:55 +01:00
* Attempt to upgrade expo 53 * Attempt upgrade nextjs * Fix a bunch of peer deps * upgrade some docs deps * fix typecheck * update the shadcn calendar component * more fixes * more fixes * revert ollama upgrade * update react version to use carets * remove react-select from landing * fix the typescript error caused by customFetch * upgrade the new grid user setting to nextjs 15 * mobile: enable react canary to support react 19.1 * upgrade react native menu * fix navigation context error
25 lines
842 B
TypeScript
25 lines
842 B
TypeScript
import serverConfig from "./config";
|
|
|
|
// Generic fetch function type that works across environments
|
|
type FetchFunction = (
|
|
input: RequestInfo | URL | string,
|
|
init?: RequestInit,
|
|
) => Promise<Response>;
|
|
|
|
// Factory function to create a custom fetch with timeout for any fetch implementation
|
|
export function createCustomFetch(fetchImpl: FetchFunction = globalThis.fetch) {
|
|
return function customFetch(
|
|
input: Parameters<typeof fetchImpl>[0],
|
|
init?: Parameters<typeof fetchImpl>[1],
|
|
): ReturnType<typeof fetchImpl> {
|
|
const timeout = serverConfig.inference.fetchTimeoutSec * 1000; // Convert to milliseconds
|
|
return fetchImpl(input, {
|
|
signal: AbortSignal.timeout(timeout),
|
|
...init,
|
|
});
|
|
};
|
|
}
|
|
|
|
// Default export for backward compatibility - uses global fetch
|
|
export const customFetch = createCustomFetch();
|