Skip to content

Commit

Permalink
env config update
Browse files Browse the repository at this point in the history
  • Loading branch information
AllStackDev1 committed Oct 24, 2024
1 parent 1aa9877 commit f6aa0e1
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 10 deletions.
4 changes: 3 additions & 1 deletion env.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,9 @@ declare global {
SESSION_SECRET?: string;

JWT_SECRET_KEY?: string;
JWT_EXPIRES_IN?: string;
JWT_DEFAULT_EXPIRES_IN?: string;
JWT_ACCESS_TOKEN_EXPIRES_IN?: string;
JWT_REFRESH_TOKEN_EXPIRES_IN?: string;

COOKIES_SECRET_KEY?: string;
COOKIES_MAX_AGE?: string;
Expand Down
26 changes: 17 additions & 9 deletions src/configs/env.config.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import dotenv from 'dotenv';
import { RedisOptions } from 'ioredis';
import { Options } from 'sequelize';

dotenv.config({ path: `.env.${process.env.NODE_ENV}` });
Expand All @@ -22,30 +23,37 @@ export const dbConfig: Options = {
database: process.env.DB_NAME!,
username: process.env.DB_USERNAME!,
password: process.env.DB_PASSWORD!,
dialectOptions: {
ssl: {
rejectUnauthorized: false,
...(isProd && {
dialectOptions: {
ssl: {
require: true,
rejectUnauthorized: false,
},
},
},
}),
};

export const redisConfig = {
export const redisConfig: RedisOptions = {
host: process.env.REDIS_HOST!,
port: +process.env.REDIS_PORT!,
username: process.env.REDIS_USER!,
password: process.env.REDIS_PASSWORD!,
showFriendlyErrorStack: true,
enableOfflineQueue: false,
maxRetriesPerRequest: null,
tls: {
rejectUnauthorized: false,
},
...(isProd && {
tls: {
rejectUnauthorized: false,
},
}),
db: 0,
};

export const jwtConfig = {
secretKey: process.env.JWT_SECRET_KEY!,
expiresIn: process.env.JWT_EXPIRES_IN!,
defaultExpiresIn: process.env.JWT_DEFAULT_EXPIRES_IN!,
accessExpiresIn: process.env.JWT_ACCESS_TOKEN_EXPIRES_IN!,
refreshExpiresIn: process.env.JWT_REFRESH_TOKEN_EXPIRES_IN!,
};

export const cookiesConfig = {
Expand Down

0 comments on commit f6aa0e1

Please sign in to comment.