Skip to content

Commit

Permalink
replace createClient for new Redis
Browse files Browse the repository at this point in the history
  • Loading branch information
blazejpass committed Apr 4, 2024
1 parent cdac8ad commit 7f5d574
Showing 1 changed file with 2 additions and 5 deletions.
7 changes: 2 additions & 5 deletions app.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ const morgan = require('morgan');
const cookieParser = require('cookie-parser');
const bodyParser = require('body-parser');
const compression = require('compression');
const redis = require('ioredis');
const Redis = require('ioredis');
const RedisStore = require('connect-redis').default;
const session = require('express-session');
const methodOverride = require('method-override');
Expand Down Expand Up @@ -123,10 +123,7 @@ let sessionStore;
const redisUrl = REDIS_URI;
if (redisUrl) {
logger.info(`Using Redis session store at '${redisUrl}'.`);
const client = redis.createClient({
url: redisUrl,
});
client.connect().catch((err) => logger.error(err));
const client = new Redis(redisUrl);

// The error event must be handled, otherwise the app crashes on redis connection errors.
// This is due to basic NodeJS behavior: https://nodejs.org/api/events.html#error-events
Expand Down

0 comments on commit 7f5d574

Please sign in to comment.