openvidu/backend/src/environment.ts
Juan Carlos Moreno García 98764597e2
Add Azure Blob Storage integration (#3)
* azure-features: added azure blob support for meet

* azure-feature: removed variables of .env files

* azure-features: added azure blob support for meet

* azure-feature: removed variables of .env files

* azure-features: fix to pass the boundary ranges test

* ci update Azure storage configuration in egress.yaml using yq

* ci: update yq command for modifying egress.yaml to use correct syntax

* ci: add logging for current storage provider in backend integration tests

* ci: update conditional syntax for Azure storage provider in backend integration tests

* feature-azure: modified package-lock

* ci: remove logging of current storage provider in backend integration tests

* ci: add pre-startup script execution for Azure setup in backend integration tests

* fix: streamline pre-startup command execution for Azure storage provider

* fix: update pre-startup command script for Azure storage provider

* fix: improve pre-startup command script for Azure storage provider

* fix: remove commented instruction for modifying egress.yaml in Azure setup

* fix: streamline pre-startup command execution in backend integration tests

* fix: correct command execution syntax in backend integration tests

* fix: add container name for Azure storage provider configuration

* fix: add container name and environment variables for Azure storage configuration

* ci: enhance recordings API tests to support Azure storage provider configuration

* ci: add support for Azure storage provider in webhook, security, global preferences, participants, meetings, and users API tests

* ci: add Azure container names for various API tests in backend integration workflow

* fix: update Azure storage container names for various API tests

* backend: fix - ensure all recordings are deleted after room security tests

* ci: remove MEET_WEBHOOK_ENABLED environment variable from OpenVidu Meet setup in all jobs

* backend: refactor storage services exports

* backend: update Azure Blob Storage references and error messages for consistency

* ci: add matrix strategy for Rooms API Tests to support multiple storage providers

* backend: rename ABS services for consistency

* backend: ensure maxResults is a number in listObjectsPaginated method

* ci: update storage provider from azure to abs in integration tests

---------

Co-authored-by: Piwccle <sergiosergi11@hotmail.com>
Co-authored-by: Carlos Santos <4a.santos@gmail.com>
2025-06-23 18:34:53 +02:00

158 lines
6.0 KiB
TypeScript

import chalk from 'chalk';
import dotenv from 'dotenv';
let envPath: string | undefined;
if (process.env.MEET_CONFIG_DIR) {
envPath = process.env.MEET_CONFIG_DIR;
} else if (process.env.NODE_ENV === 'development') {
envPath = '.env.dev';
} else if (process.env.NODE_ENV === 'test' || process.env.NODE_ENV === 'ci') {
envPath = '.env.test';
} else {
envPath = undefined;
}
dotenv.config(envPath ? { path: envPath } : {});
export const {
SERVER_PORT = 6080,
SERVER_CORS_ORIGIN = '*',
MEET_LOG_LEVEL = 'info',
MEET_NAME_ID = 'openviduMeet',
// Authentication configuration
MEET_API_KEY = '',
MEET_ADMIN_USER = 'admin',
MEET_ADMIN_SECRET = 'admin',
// Token expiration times
MEET_ACCESS_TOKEN_EXPIRATION = '2h',
MEET_REFRESH_TOKEN_EXPIRATION = '1d',
MEET_PARTICIPANT_TOKEN_EXPIRATION = '6h',
MEET_RECORDING_TOKEN_EXPIRATION = '2h',
// Webhook configuration
MEET_WEBHOOK_ENABLED = 'false',
MEET_WEBHOOK_URL = 'http://localhost:5080/webhook',
// LiveKit configuration
LIVEKIT_URL = 'ws://localhost:7880',
LIVEKIT_URL_PRIVATE = LIVEKIT_URL, // Uses LIVEKIT_URL if not explicitly set
LIVEKIT_API_KEY = 'devkey',
LIVEKIT_API_SECRET = 'secret',
MEET_PREFERENCES_STORAGE_MODE = 's3', // Options: 's3', 'abs'
// S3 configuration
MEET_S3_BUCKET = 'openvidu-appdata',
MEET_S3_SUBBUCKET = 'openvidu-meet',
MEET_S3_SERVICE_ENDPOINT = 'http://localhost:9000',
MEET_S3_ACCESS_KEY = 'minioadmin',
MEET_S3_SECRET_KEY = 'minioadmin',
MEET_AWS_REGION = 'us-east-1',
MEET_S3_WITH_PATH_STYLE_ACCESS = 'true',
//Azure Blob storage configuration
MEET_AZURE_CONTAINER_NAME = 'openvidu-appdata',
MEET_AZURE_SUBCONATAINER_NAME = 'openvidu-meet',
MEET_AZURE_ACCOUNT_NAME = '',
MEET_AZURE_ACCOUNT_KEY = '',
// Redis configuration
MEET_REDIS_HOST: REDIS_HOST = 'localhost',
MEET_REDIS_PORT: REDIS_PORT = 6379,
MEET_REDIS_USERNAME: REDIS_USERNAME = '',
MEET_REDIS_PASSWORD: REDIS_PASSWORD = 'redispassword',
MEET_REDIS_DB: REDIS_DB = '0',
// Redis Sentinel configuration
MEET_REDIS_SENTINEL_HOST_LIST: REDIS_SENTINEL_HOST_LIST = '',
MEET_REDIS_SENTINEL_PASSWORD: REDIS_SENTINEL_PASSWORD = '',
MEET_REDIS_SENTINEL_MASTER_NAME: REDIS_SENTINEL_MASTER_NAME = 'openvidu',
// Deployment configuration
MODULES_FILE = undefined,
MODULE_NAME = 'openviduMeet',
ENABLED_MODULES = ''
} = process.env;
export function checkModuleEnabled() {
if (MODULES_FILE) {
const moduleName = MODULE_NAME;
const enabledModules = ENABLED_MODULES.split(',').map((module) => module.trim());
if (!enabledModules.includes(moduleName)) {
console.error(`Module ${moduleName} is not enabled`);
process.exit(0);
}
}
}
export const logEnvVars = () => {
const credential = chalk.yellow;
const text = chalk.cyanBright;
console.log(' ');
console.log('---------------------------------------------------------');
console.log('OpenVidu Meet Server Configuration');
console.log('---------------------------------------------------------');
console.log('SERVICE NAME ID: ', text(MEET_NAME_ID));
console.log('CORS ORIGIN:', text(SERVER_CORS_ORIGIN));
console.log('MEET LOG LEVEL: ', text(MEET_LOG_LEVEL));
console.log('MEET API KEY: ', credential('****' + MEET_API_KEY.slice(-3)));
console.log('MEET ADMIN USER: ', credential('****' + MEET_ADMIN_USER.slice(-3)));
console.log('MEET ADMIN PASSWORD: ', credential('****' + MEET_ADMIN_SECRET.slice(-3)));
console.log('MEET ACCESS TOKEN EXPIRATION: ', text(MEET_ACCESS_TOKEN_EXPIRATION));
console.log('MEET REFRESH TOKEN EXPIRATION: ', text(MEET_REFRESH_TOKEN_EXPIRATION));
console.log('MEET PREFERENCES STORAGE:', text(MEET_PREFERENCES_STORAGE_MODE));
console.log('MEET_WEBHOOK_ENABLED:', text(MEET_WEBHOOK_ENABLED));
if (MEET_WEBHOOK_ENABLED === 'true') {
console.log('MEET_WEBHOOK_URL:', text(MEET_WEBHOOK_URL));
}
console.log('---------------------------------------------------------');
console.log('LIVEKIT Configuration');
console.log('---------------------------------------------------------');
console.log('LIVEKIT URL: ', text(LIVEKIT_URL));
console.log('LIVEKIT URL PRIVATE: ', text(LIVEKIT_URL_PRIVATE));
console.log('LIVEKIT API SECRET: ', credential('****' + LIVEKIT_API_SECRET.slice(-3)));
console.log('LIVEKIT API KEY: ', credential('****' + LIVEKIT_API_KEY.slice(-3)));
console.log('---------------------------------------------------------');
if (MEET_PREFERENCES_STORAGE_MODE === 's3') {
console.log('S3 Configuration');
console.log('---------------------------------------------------------');
console.log('MEET S3 BUCKET:', text(MEET_S3_BUCKET));
console.log('MEET S3 SERVICE ENDPOINT:', text(MEET_S3_SERVICE_ENDPOINT));
console.log('MEET S3 ACCESS KEY:', credential('****' + MEET_S3_ACCESS_KEY.slice(-3)));
console.log('MEET S3 SECRET KEY:', credential('****' + MEET_S3_SECRET_KEY.slice(-3)));
console.log('MEET AWS REGION:', text(MEET_AWS_REGION));
console.log('MEET S3 WITH PATH STYLE ACCESS:', text(MEET_S3_WITH_PATH_STYLE_ACCESS));
console.log('---------------------------------------------------------');
} else if (MEET_PREFERENCES_STORAGE_MODE === 'abs') {
console.log('Azure Blob Storage Configuration');
console.log('---------------------------------------------------------');
console.log('MEET AZURE ACCOUNT NAME:', text(MEET_AZURE_ACCOUNT_NAME));
console.log('MEET AZURE ACCOUNT KEY:', credential('****' + MEET_AZURE_ACCOUNT_KEY.slice(-3)));
console.log('MEET AZURE CONTAINER NAME:', text(MEET_AZURE_CONTAINER_NAME));
console.log('---------------------------------------------------------');
}
console.log('Redis Configuration');
console.log('---------------------------------------------------------');
console.log('REDIS HOST:', text(REDIS_HOST));
console.log('REDIS PORT:', text(REDIS_PORT));
console.log('REDIS USERNAME:', credential('****' + REDIS_USERNAME.slice(-3)));
console.log('REDIS PASSWORD:', credential('****' + REDIS_PASSWORD.slice(-3)));
if (REDIS_SENTINEL_HOST_LIST !== '') {
console.log('REDIS SENTINEL IS ENABLED');
console.log('REDIS SENTINEL HOST LIST:', text(REDIS_SENTINEL_HOST_LIST));
}
console.log('---------------------------------------------------------');
console.log(' ');
};