MCPcopy
hub / github.com/apify/crawlee / getClient

Method getClient

packages/impit-client/src/index.ts:38–52  ·  view source on GitHub ↗
(options: ImpitOptions)

Source from the content-addressed store, hash-verified

36 private clientCache: LruCache<{ client: Impit; cookieJar: ToughCookieJar }> = new LruCache({ maxLength: 10 });
37
38 private getClient(options: ImpitOptions) {
39 const { cookieJar, ...rest } = options;
40
41 const cacheKey = JSON.stringify(rest);
42 const existingClient = this.clientCache.get(cacheKey);
43
44 if (existingClient && (!cookieJar || existingClient.cookieJar === cookieJar)) {
45 return existingClient.client;
46 }
47
48 const client = new Impit(options);
49 this.clientCache.add(cacheKey, { client, cookieJar: cookieJar as ToughCookieJar });
50
51 return client;
52 }
53
54 constructor(options?: Omit<ImpitOptions, 'proxyUrl'> & { maxRedirects?: number }) {
55 this.impitOptions = options ?? {};

Callers 1

getResponseMethod · 0.95

Calls 2

getMethod · 0.65
addMethod · 0.45

Tested by

no test coverage detected