-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: refresh token working, finishing egvs
- Loading branch information
1 parent
194962e
commit b6bf828
Showing
21 changed files
with
873 additions
and
243 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import { create } from "zustand"; | ||
import { createJSONStorage, persist } from "zustand/middleware"; | ||
|
||
import { zustandStorage } from "~/lib/storage"; | ||
|
||
interface SyncState { | ||
lastSyncedTime: Date | null; | ||
setLastSyncedTime: (date: Date) => void; | ||
} | ||
|
||
export const useSyncStore = create<SyncState>()( | ||
persist( | ||
(set) => ({ | ||
lastSyncedTime: null, | ||
setLastSyncedTime: (date: Date) => set({ lastSyncedTime: date }), | ||
}), | ||
{ | ||
name: "sync-storage", // unique name | ||
storage: createJSONStorage(() => zustandStorage), | ||
}, | ||
), | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import { createTRPCClient, httpBatchLink } from "@trpc/client"; | ||
import SuperJSON from "superjson"; | ||
|
||
import type { AppRouter } from "@hyper/api"; | ||
|
||
import { getBaseUrl } from "~/utils/base-url"; | ||
import { getDexcomTokens } from "~/utils/dexcom-store"; | ||
|
||
export const helperClient = createTRPCClient<AppRouter>({ | ||
links: [ | ||
httpBatchLink({ | ||
transformer: SuperJSON, | ||
url: `${getBaseUrl()}/api/trpc`, | ||
headers() { | ||
const headers = new Map<string, string>(); | ||
headers.set("x-trpc-source", "expo-react"); | ||
|
||
// Add Dexcom tokens to headers | ||
const dexcomTokens = getDexcomTokens(); | ||
if (dexcomTokens) { | ||
headers.set("X-Dexcom-Access-Token", dexcomTokens.accessToken); | ||
headers.set("X-Dexcom-Refresh-Token", dexcomTokens.refreshToken); | ||
headers.set("X-Dexcom-Expires-At", dexcomTokens.expiresAt.toString()); | ||
} | ||
|
||
return Object.fromEntries(headers); | ||
}, | ||
}), | ||
], | ||
}); |
Oops, something went wrong.