import { OAuth, RedisTokenStore } from './oauth.ts'; import { useContextKey } from '@kevisual/use-config/context'; import { Redis } from 'ioredis'; export const oauth = useContextKey('oauth', () => { const redis = useContextKey('redis'); const store = new RedisTokenStore(redis); // redis是promise if (redis instanceof Promise) { redis.then((r) => { store.setRedis(r); }); } else if (redis) { store.setRedis(redis); } const oauth = new OAuth(store); return oauth; });