mirror of
https://github.com/Nezumi-2711/onedrive-vercel-index.git
synced 2026-09-22 13:38:45 +00:00
add support for reds key prefix
This commit is contained in:
@@ -13,6 +13,9 @@ module.exports = {
|
|||||||
// /public directory of your GitHub project (not your OneDrive folder!), and referenced here by its relative path to /public.
|
// /public directory of your GitHub project (not your OneDrive folder!), and referenced here by its relative path to /public.
|
||||||
icon: '/icons/128.png',
|
icon: '/icons/128.png',
|
||||||
|
|
||||||
|
// Prefix for KV Storage
|
||||||
|
kvPrefix: process.env.KV_PREFIX || 'spwoo',
|
||||||
|
|
||||||
// The name of your website. Present alongside your icon.
|
// The name of your website. Present alongside your icon.
|
||||||
title: "Spencer's OneDrive",
|
title: "Spencer's OneDrive",
|
||||||
|
|
||||||
|
|||||||
@@ -1,12 +1,12 @@
|
|||||||
import Redis from 'ioredis'
|
import Redis from 'ioredis'
|
||||||
|
import siteConfig from '../config/site.config'
|
||||||
// Persistent key-value store is provided by Redis, hosted on Upstash
|
// Persistent key-value store is provided by Redis, hosted on Upstash
|
||||||
// https://vercel.com/integrations/upstash
|
// https://vercel.com/integrations/upstash
|
||||||
const kv = new Redis(process.env.REDIS_URL)
|
const kv = new Redis(process.env.REDIS_URL)
|
||||||
|
|
||||||
export async function getOdAuthTokens(): Promise<{ accessToken: unknown; refreshToken: unknown }> {
|
export async function getOdAuthTokens(): Promise<{ accessToken: unknown; refreshToken: unknown }> {
|
||||||
const accessToken = await kv.get('access_token')
|
const accessToken = await kv.get(`${siteConfig.kvPrefix}_access_token`)
|
||||||
const refreshToken = await kv.get('refresh_token')
|
const refreshToken = await kv.get(`${siteConfig.kvPrefix}_refresh_token`)
|
||||||
|
|
||||||
return {
|
return {
|
||||||
accessToken,
|
accessToken,
|
||||||
@@ -23,6 +23,6 @@ export async function storeOdAuthTokens({
|
|||||||
accessTokenExpiry: number
|
accessTokenExpiry: number
|
||||||
refreshToken: string
|
refreshToken: string
|
||||||
}): Promise<void> {
|
}): Promise<void> {
|
||||||
await kv.set('access_token', accessToken, 'ex', accessTokenExpiry)
|
await kv.set(`${siteConfig.kvPrefix}_access_token`, accessToken, 'ex', accessTokenExpiry)
|
||||||
await kv.set('refresh_token', refreshToken)
|
await kv.set(`${siteConfig.kvPrefix}_refresh_token`, refreshToken)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user