MCPcopy Create free account
hub / github.com/Bytez-com/docs / constructor

Method constructor

sdk/javascript/src/client.ts:4–34  ·  view source on GitHub ↗
(
    apiKey: string,
    dev = false,
    isBrowser = typeof window !== "undefined"
  )

Source from the content-addressed store, hash-verified

2
3export default class Client {
4 constructor(
5 apiKey: string,
6 dev = false,
7 isBrowser = typeof window !== "undefined"
8 ) {
9 this.#isBrowser = isBrowser;
10 this.host = `http${
11 dev ? "://localhost:8080" : "s://api.bytez.com"
12 }/models/v2/`;
13 this.headers = {
14 lang: "javascript",
15 Authorization: `Key ${apiKey}`,
16 "content-type": "application/json"
17 };
18
19 if (isBrowser === false) {
20 import("stream").then(module => {
21 this.#Readable = module.Readable ?? module.default?.Readable;
22 });
23 // make undici invisible to webpack's static analysis
24 new Function('return import("undici")')().then(({ Agent }) => {
25 this.#dispatcher = new Agent({
26 keepAliveTimeout: this.#timeout,
27 keepAliveMaxTimeout: this.#timeout,
28 connectTimeout: this.#timeout,
29 headersTimeout: this.#timeout,
30 bodyTimeout: this.#timeout
31 });
32 });
33 }
34 }
35 #Readable: any;
36 #isBrowser: boolean;
37 #dispatcher?: any;

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected