diff --git a/.env.example b/.env.example index 148a057..b7eaad1 100644 --- a/.env.example +++ b/.env.example @@ -2,4 +2,5 @@ PORT_LISTEN=5000 DATABASE_HOST=localhost DATABASE_PORT=27017 REDIS_HOST=localhost -REDIS_PORT=6379 \ No newline at end of file +REDIS_PORT=6379 +REDIS_PASSWORD=aruppiTime \ No newline at end of file diff --git a/src/database/connection.ts b/src/database/connection.ts index 9f16e13..6eb1ab2 100644 --- a/src/database/connection.ts +++ b/src/database/connection.ts @@ -1,5 +1,9 @@ import mongoose from 'mongoose'; import redis, { RedisClient } from 'redis'; +import dotenv from 'dotenv'; + +// Configuring dotenv to read the variable from .env file +dotenv.config(); /* Create the connection to the database @@ -35,6 +39,7 @@ export const createConnectionMongo = (databaseObj: { export const redisClient: RedisClient = redis.createClient({ host: process.env.REDIS_HOST, port: parseInt(process.env.REDIS_PORT!), + password: process.env.REDIS_PASSWORD, }); redisClient.on('connect', () => {