Comparing version 0.1.3 to 0.1.4
@@ -16,3 +16,2 @@ import * as models from './models'; | ||
recommend(entity: models.Entity, target: string, limit: number): Promise<models.tearexResponse<Recommendation[]>>; | ||
dropStage(stage: string): Promise<models.tearexResponse<number>>; | ||
} | ||
@@ -35,5 +34,4 @@ declare class TeaRex implements TeaRexService { | ||
recommend(entity: models.Entity, target: string, limit?: number): Promise<models.tearexResponse<models.Recommendation[]>>; | ||
dropStage(stage: string): Promise<models.tearexResponse<number>>; | ||
} | ||
declare const tearex: TeaRex; | ||
export default tearex; | ||
export = tearex; |
{ | ||
"name": "tearex", | ||
"version": "0.1.3", | ||
"version": "0.1.4", | ||
"private": false, | ||
@@ -5,0 +5,0 @@ "description": "This package provides a NodeJS SDK for the [tearex.ai](https://tearex.ai) Recommendation Engine API. If you don't have a tearex.ai account, you can request one here: [tearex.ai](https://tearex.ai/#contact).", |
@@ -5,2 +5,3 @@ import * as models from './models'; | ||
import { ApolloClient, gql, HttpLink, InMemoryCache, DefaultOptions} from '@apollo/client/core/index.js'; | ||
import { setContext } from '@apollo/client/link/context'; | ||
import {Recommendation} from "./models"; | ||
@@ -64,2 +65,12 @@ | ||
this.url = url || process.env.TEAREX_URL || "http://localhost:4000"; | ||
const authLink = setContext((_, { headers }) => { | ||
return { | ||
headers: { | ||
...headers, | ||
"x-api-key": apiKey || process.env.TEAREX_API_KEY || "", | ||
} | ||
} | ||
}); | ||
this.client = new ApolloClient({ | ||
@@ -70,6 +81,3 @@ cache: new InMemoryCache({ | ||
}), | ||
link: new HttpLink({uri: this.url, fetch}), | ||
headers: { | ||
"x-api-key": apiKey || process.env.TEAREX_API_KEY || "", | ||
}, | ||
link: authLink.concat(new HttpLink({uri: this.url, fetch})), | ||
defaultOptions | ||
@@ -76,0 +84,0 @@ }); |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
14075142
17373