Skip to content

Commit

Permalink
replace authToken with apiKey
Browse files Browse the repository at this point in the history
  • Loading branch information
sywhb committed Mar 11, 2024
1 parent f8b6b64 commit ce99d23
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 8 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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',
})

Expand Down Expand Up @@ -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. |

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
11 changes: 8 additions & 3 deletions src/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {
} from './graphql'

export interface ClientOptions {
authToken: string
apiKey: string
baseUrl?: string
timeoutMs?: number
}
Expand Down Expand Up @@ -98,6 +98,8 @@ export interface SearchItemResponse {

export interface ItemUpdatesParameters {
since: string
after?: number
first?: number
}

export type ItemUpdateReason = 'CREATED' | 'UPDATED' | 'DELETED'
Expand Down Expand Up @@ -153,7 +155,7 @@ export class Omnivore {
exchanges: [fetchExchange],
fetchOptions: () => ({
headers: {
Authorization: clientOptions.authToken,
Authorization: clientOptions.apiKey,
},
timeout: clientOptions.timeoutMs || 0,
}),
Expand Down Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions src/graphql.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
1 change: 1 addition & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ export {
ItemFormat,
ItemType,
ItemUpdateReason,
ItemUpdatesParameters,
ItemUpdatesResponse,
Label,
LibraryItemState,
Expand Down

0 comments on commit ce99d23

Please sign in to comment.