From f490c81cf1c5bdf4e062a05f600d027ba7631afb Mon Sep 17 00:00:00 2001 From: capitanwesler Date: Sat, 27 Mar 2021 23:36:55 +0000 Subject: [PATCH] =?UTF-8?q?=F0=9F=A4=96=20Setting=20the=20password=20for?= =?UTF-8?q?=20redis-server=20in=20.env?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .env.example | 3 ++- src/database/connection.ts | 5 +++++ 2 files changed, 7 insertions(+), 1 deletion(-) 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', () => {