(
apiKey: string,
dev = false,
isBrowser = typeof window !== "undefined"
)
| 2 | |
| 3 | export 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; |
nothing calls this directly
no outgoing calls
no test coverage detected