File size: 561 Bytes
f4bd24d
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
import { HttpClient } from "@http";

export function newHttpClient(): HttpClient {
  const apiKey = process.env.CONTEXT7_API_KEY || process.env.API_KEY;

  if (!apiKey) {
    throw new Error("CONTEXT7_API_KEY or API_KEY environment variable is required for tests");
  }

  return new HttpClient({
    baseUrl: process.env.CONTEXT7_BASE_URL || "https://context7.com/api",
    headers: {
      Authorization: `Bearer ${apiKey}`,
    },
    retry: {
      retries: 3,
      backoff: (retryCount) => Math.exp(retryCount) * 50,
    },
    cache: "no-store",
  });
}