Skip to content

Commit

Permalink
Refactor Redis configuration in auth options
Browse files Browse the repository at this point in the history
  • Loading branch information
walnuts1018 committed Nov 11, 2023
1 parent e4db65d commit 2280d40
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions front/src/app/api/auth/[...nextauth]/options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,22 @@ import Redis from 'ioredis';
import crypto from 'crypto';
import AsyncLock from 'async-lock';

const redisSentinelPort: number = Number(process.env.REDIS_SENTINEL_PORT);
const redisDB: number = Number(process.env.REDIS_DB);

const redis = new Redis({
sentinels: [{
host: process.env.REDIS_SENTINEL_HOST,
port: Number(process.env.REDIS_SENTINEL_PORT),
port: redisSentinelPort,
}],
sentinelPassword: process.env.REDIS_PASSWORD,
password: process.env.REDIS_PASSWORD,
name: process.env.REDIS_SENTINEL_NAME,
db: Number(process.env.REDIS_DB),
name: process.env.REDIS_SENTINEL_NAME || "mymaster",
db: redisDB,
});

const cachePassword = process.env.CACHE_PASSWORD || "password";
const cacheKey = crypto.scryptSync(cachePassword, "salt", 32);

const lock = new AsyncLock({ timeout: 10000 });

export const authOptions: NextAuthOptions = {
Expand Down

0 comments on commit 2280d40

Please sign in to comment.