mirror of
https://github.com/Nezumi-2711/onedrive-vercel-index.git
synced 2026-09-22 13:38:45 +00:00
use ioredis instead of keyv
This commit is contained in:
@@ -1,14 +1,8 @@
|
||||
// This should be only used on the server side, where the tokens are stored with KV store using
|
||||
// a file system based storage. The tokens are stored in the file system as JSON at /tmp path.
|
||||
|
||||
import Keyv from 'keyv'
|
||||
import Redis from 'ioredis'
|
||||
|
||||
// Persistent key-value store is provided by Redis, hosted on Upstash
|
||||
// https://vercel.com/integrations/upstash
|
||||
console.log(process.env.REDIS_URL)
|
||||
|
||||
const kv = new Keyv(process.env.REDIS_URL)
|
||||
kv.on('error', err => console.log('Connection Error', err))
|
||||
const kv = new Redis(process.env.REDIS_URL)
|
||||
|
||||
export async function getOdAuthTokens(): Promise<{ accessToken: unknown; refreshToken: unknown }> {
|
||||
const accessToken = await kv.get('access_token')
|
||||
@@ -29,6 +23,6 @@ export async function storeOdAuthTokens({
|
||||
accessTokenExpiry: number
|
||||
refreshToken: string
|
||||
}): Promise<void> {
|
||||
await kv.set('access_token', accessToken, accessTokenExpiry)
|
||||
await kv.set('access_token', accessToken, 'ex', accessTokenExpiry)
|
||||
await kv.set('refresh_token', refreshToken)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user