-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.ts
49 lines (41 loc) · 1.17 KB
/
index.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
import { createConfiguration } from "./configuration"
import { PromiseDefaultApi as DefaultApi } from './types/PromiseAPI';
const getConfig = (apiKey: string) => {
return createConfiguration({
authMethods: {
BearerAuth: {
'tokenProvider': {
getToken: async () => {
return apiKey || '';
}
}
}
}
});
}
const getApiInstance = (apiKey: string) => {
const configuration = getConfig(apiKey);
return new DefaultApi(configuration);
};
interface IConfig {
apiKey: string;
}
export default class Perplexity {
private instance: DefaultApi;
constructor(config: IConfig) {
this.instance = getApiInstance(config.apiKey);
}
public client(): DefaultApi {
return this.instance;
}
}
export * from "./http/http";
export * from "./auth/auth";
export * from "./models/all";
export { createConfiguration } from "./configuration"
export { Configuration } from "./configuration"
export * from "./apis/exception";
export * from "./servers";
export { RequiredError } from "./apis/baseapi";
export { PromiseMiddleware as Middleware } from './middleware';
export { PromiseDefaultApi as DefaultApi } from './types/PromiseAPI';