From 2599b1d3269c6c0abcffe74b93e48be3a7fed6bb Mon Sep 17 00:00:00 2001 From: Mir Arif Hasan Date: Tue, 1 Aug 2023 20:45:55 +0600 Subject: [PATCH] chore: check added if ALLOWED_AUTH_PROVIDERS is there in the env file or not --- packages/hoppscotch-backend/src/main.ts | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/packages/hoppscotch-backend/src/main.ts b/packages/hoppscotch-backend/src/main.ts index 920f7cce9..5515e804b 100644 --- a/packages/hoppscotch-backend/src/main.ts +++ b/packages/hoppscotch-backend/src/main.ts @@ -6,10 +6,21 @@ import { VersioningType } from '@nestjs/common'; import * as session from 'express-session'; import { emitGQLSchemaFile } from './gql-schema'; +function checkRequiredEnvVars(requiredEnvVariables: string[]) { + for (const envVar of requiredEnvVariables) { + if (!process.env[envVar]) { + console.error(`Environment variable "${envVar}" is missing or not set.`); + process.exit(1); // Exit the application with a non-zero status code to indicate an error + } + } +} + async function bootstrap() { console.log(`Running in production: ${process.env.PRODUCTION}`); console.log(`Port: ${process.env.PORT}`); + checkRequiredEnvVars(['ALLOWED_AUTH_PROVIDERS']); + const app = await NestFactory.create(AppModule); app.use(