Remove buildFontUrl, measureText, uncached, invalidateCache, fetchJsonWithFlareSolver, upsertPermission, deletePermission, bulkImportPermissions, clearAllPermissions, bulkDeletePermissions, bulkDeletePhotos, userReplyTicket, closeTicketByUser. Update staff-smoke-contract test for bulkDeletePhotos removal.
42 lines
893 B
TypeScript
42 lines
893 B
TypeScript
const FLARESOLVERR_URL =
|
|
process.env.FLARESOLVERR_URL ?? "http://localhost:8191";
|
|
|
|
const FLARESOLVERR_API = `${FLARESOLVERR_URL}/v1`;
|
|
|
|
export async function fetchWithFlareSolver(
|
|
url: string,
|
|
timeout = 30000,
|
|
): Promise<string> {
|
|
const res = await fetch(FLARESOLVERR_API, {
|
|
method: "POST",
|
|
headers: { "Content-Type": "application/json" },
|
|
body: JSON.stringify({
|
|
cmd: "request.get",
|
|
url,
|
|
maxTimeout: timeout,
|
|
}),
|
|
signal: AbortSignal.timeout(timeout + 5000),
|
|
});
|
|
|
|
if (!res.ok) {
|
|
throw new Error(
|
|
`FlareSolverr request failed: ${res.status} ${res.statusText}`,
|
|
);
|
|
}
|
|
|
|
const data = (await res.json()) as {
|
|
solution?: { response: string };
|
|
error?: string;
|
|
};
|
|
|
|
if (data.error) {
|
|
throw new Error(`FlareSolverr error: ${data.error}`);
|
|
}
|
|
|
|
if (!data.solution) {
|
|
throw new Error("FlareSolverr: no solution in response");
|
|
}
|
|
|
|
return data.solution.response;
|
|
}
|