replace authToken with apiKey

This commit is contained in:
Hongbo Wu
2024-03-11 10:33:47 +08:00
parent f8b6b64140
commit ce99d2313e
5 changed files with 14 additions and 8 deletions
+2 -2
View File
@@ -20,7 +20,7 @@ Import the `Omnivore` class and create a new instance with your **API Key** and
import { Omnivore } from '@omnivore-app/api'
const omnivore = new Omnivore({
authToken: 'your api key',
apiKey: 'your api key',
baseUrl: 'https://api-prod.omnivore.app',
})
@@ -175,7 +175,7 @@ The `Omnivore` class accepts an options object with the following properties:
| Option | Default value | Type | Description |
| ----------- | --------------------------------- | -------- | ------------------------------------------------------------------------------------ |
| `authToken` | `undefined` | `string` | API key required for authentication. |
| `apiKey` | `undefined` | `string` | API key required for authentication. |
| `baseUrl` | `"https://api-prod.omnivore.app"` | `string` | The base URL for sending API requests. This can be changed to a local-hosted server. |
| `timeoutMs` | `0` | `number` | Number of milliseconds to wait before timeout. |
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "@omnivore-app/api",
"version": "1.0.3",
"version": "1.0.4",
"description": "Omnivore API Client Library for Node.js",
"main": "./dist/src/index.js",
"types": "./dist/src/index.d.ts",
+8 -3
View File
@@ -8,7 +8,7 @@ import {
} from './graphql'
export interface ClientOptions {
authToken: string
apiKey: string
baseUrl?: string
timeoutMs?: number
}
@@ -98,6 +98,8 @@ export interface SearchItemResponse {
export interface ItemUpdatesParameters {
since: string
after?: number
first?: number
}
export type ItemUpdateReason = 'CREATED' | 'UPDATED' | 'DELETED'
@@ -153,7 +155,7 @@ export class Omnivore {
exchanges: [fetchExchange],
fetchOptions: () => ({
headers: {
Authorization: clientOptions.authToken,
Authorization: clientOptions.apiKey,
},
timeout: clientOptions.timeoutMs || 0,
}),
@@ -188,7 +190,10 @@ export class Omnivore {
params: ItemUpdatesParameters,
): Promise<ItemUpdatesResponse> => {
const { data, error } = await this.client
.query(UpdatesSinceQuery, params)
.query(UpdatesSinceQuery, {
...params,
after: params.after ? String(params.after) : undefined,
})
.toPromise()
const updatesSince = data?.updatesSince
+2 -2
View File
@@ -128,8 +128,8 @@ export const SearchQuery = graphql(
export const UpdatesSinceQuery = graphql(
`
query UpdatesSince($since: Date!) {
updatesSince(since: $since) {
query UpdatesSince($after: String, $first: Int, $since: Date!) {
updatesSince(after: $after, first: $first, since: $since) {
__typename
... on UpdatesSinceSuccess {
edges {
+1
View File
@@ -7,6 +7,7 @@ export {
ItemFormat,
ItemType,
ItemUpdateReason,
ItemUpdatesParameters,
ItemUpdatesResponse,
Label,
LibraryItemState,