Skip to content

Commit

Permalink
backend: Updated S3 env var names
Browse files Browse the repository at this point in the history
  • Loading branch information
CSantosM committed Jul 2, 2024
1 parent d2a2455 commit ef3098b
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 34 deletions.
10 changes: 5 additions & 5 deletions openvidu-call-back/src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ export const LIVEKIT_API_KEY = process.env.LIVEKIT_API_KEY || 'devkey';
export const LIVEKIT_API_SECRET = process.env.LIVEKIT_API_SECRET || 'secret';

// S3 configuration
export const CALL_AWS_S3_BUCKET = process.env.CALL_AWS_S3_BUCKET || 'openvidu';
export const CALL_AWS_S3_SERVICE_ENDPOINT = process.env.CALL_AWS_S3_SERVICE_ENDPOINT || 'http://localhost:9000';
export const CALL_AWS_ACCESS_KEY = process.env.CALL_AWS_ACCESS_KEY || 'minioadmin';
export const CALL_AWS_SECRET_KEY = process.env.CALL_AWS_SECRET_KEY || 'minioadmin';
export const CALL_S3_BUCKET = process.env.CALL_S3_BUCKET || 'openvidu';
export const CALL_S3_SERVICE_ENDPOINT = process.env.CALL_S3_SERVICE_ENDPOINT || 'http://localhost:9000';
export const CALL_S3_ACCESS_KEY = process.env.CALL_S3_ACCESS_KEY || 'minioadmin';
export const CALL_S3_SECRET_KEY = process.env.CALL_S3_SECRET_KEY || 'minioadmin';
export const CALL_AWS_REGION = process.env.CALL_AWS_REGION || 'us-east-1';
export const CALL_AWS_S3_WITH_PATH_STYLE_ACCESS = process.env.CALL_AWS_S3_WITH_PATH_STYLE_ACCESS || 'true';
export const CALL_S3_WITH_PATH_STYLE_ACCESS = process.env.CALL_S3_WITH_PATH_STYLE_ACCESS || 'true';
18 changes: 9 additions & 9 deletions openvidu-call-back/src/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@ import {
CALL_USER,
CALL_ADMIN_SECRET,
LIVEKIT_URL_PRIVATE,
CALL_AWS_S3_BUCKET,
CALL_AWS_S3_SERVICE_ENDPOINT,
CALL_AWS_ACCESS_KEY,
CALL_AWS_SECRET_KEY,
CALL_S3_BUCKET,
CALL_S3_SERVICE_ENDPOINT,
CALL_S3_ACCESS_KEY,
CALL_S3_SECRET_KEY,
CALL_ADMIN_USER,
CALL_AWS_REGION,
CALL_LOG_LEVEL
Expand Down Expand Up @@ -86,11 +86,11 @@ app.listen(SERVER_PORT, () => {
console.log('---------------------------------------------------------');
console.log(' S3 Configuration');
console.log('---------------------------------------------------------');
console.log('CALL_AWS_S3_BUCKET:', text(CALL_AWS_S3_BUCKET));
console.log('CALL_AWS_S3_SERVICE_ENDPOINT:', text(CALL_AWS_S3_SERVICE_ENDPOINT));
console.log('CALL_AWS_ACCESS_KEY:', credential('****' + CALL_AWS_ACCESS_KEY.slice(-3)));
console.log('CALL_AWS_SECRET_KEY:', credential('****' + CALL_AWS_SECRET_KEY.slice(-3)));
console.log('CALL_AWS_REGION:', text(CALL_AWS_REGION));
console.log('CALL S3 BUCKET:', text(CALL_S3_BUCKET));
console.log('CALL S3 SERVICE ENDPOINT:', text(CALL_S3_SERVICE_ENDPOINT));
console.log('CALL S3 ACCESS KEY:', credential('****' + CALL_S3_ACCESS_KEY.slice(-3)));
console.log('CALL S3 SECRET KEY:', credential('****' + CALL_S3_SECRET_KEY.slice(-3)));
console.log('CALL AWS REGION:', text(CALL_AWS_REGION));
console.log('---------------------------------------------------------');});

export default app;
4 changes: 2 additions & 2 deletions openvidu-call-back/src/services/recording.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import { DataTopic } from '../models/signal.model.js';
import { LoggerService } from './logger.service.js';
import { RecordingInfo, RecordingStatus } from '../models/recording.model.js';
import { RecordingHelper } from '../helpers/recording.helper.js';
import { CALL_AWS_S3_BUCKET } from '../config.js';
import { CALL_S3_BUCKET } from '../config.js';
import { RoomService } from './room.service.js';

export class RecordingService {
Expand Down Expand Up @@ -219,7 +219,7 @@ export class RecordingService {
const parts = range.replace(/bytes=/, '').split('-');
const start = parseInt(parts[0], 10);
const end = parts[1] ? parseInt(parts[1], 10) : fileSize - 1;
const fileStream = await this.s3Service.getObjectAsStream(recordingPath, CALL_AWS_S3_BUCKET, {
const fileStream = await this.s3Service.getObjectAsStream(recordingPath, CALL_S3_BUCKET, {
start,
end
});
Expand Down
36 changes: 18 additions & 18 deletions openvidu-call-back/src/services/s3.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@ import {
} from '@aws-sdk/client-s3';

import {
CALL_AWS_ACCESS_KEY,
CALL_S3_ACCESS_KEY,
CALL_AWS_REGION,
CALL_AWS_S3_BUCKET,
CALL_AWS_S3_SERVICE_ENDPOINT,
CALL_AWS_SECRET_KEY,
CALL_AWS_S3_WITH_PATH_STYLE_ACCESS
CALL_S3_BUCKET,
CALL_S3_SERVICE_ENDPOINT,
CALL_S3_SECRET_KEY,
CALL_S3_WITH_PATH_STYLE_ACCESS
} from '../config.js';
import { errorS3NotAvailable, internalError } from '../models/error.model.js';
import { Readable } from 'stream';
Expand All @@ -35,11 +35,11 @@ export class S3Service {
const config: S3ClientConfig = {
region: CALL_AWS_REGION,
credentials: {
accessKeyId: CALL_AWS_ACCESS_KEY,
secretAccessKey: CALL_AWS_SECRET_KEY
accessKeyId: CALL_S3_ACCESS_KEY,
secretAccessKey: CALL_S3_SECRET_KEY
},
endpoint: CALL_AWS_S3_SERVICE_ENDPOINT,
forcePathStyle: CALL_AWS_S3_WITH_PATH_STYLE_ACCESS === 'true'
endpoint: CALL_S3_SERVICE_ENDPOINT,
forcePathStyle: CALL_S3_WITH_PATH_STYLE_ACCESS === 'true'
};

this.s3 = new S3Client(config);
Expand All @@ -60,7 +60,7 @@ export class S3Service {
* @param CALL_AWS_S3_BUCKET - The name of the S3 bucket.
* @returns A boolean indicating whether the file exists or not.
*/
async exists(path: string, bucket: string = CALL_AWS_S3_BUCKET) {
async exists(path: string, bucket: string = CALL_S3_BUCKET) {
try {
await this.getHeaderObject(path, bucket);
return true;
Expand All @@ -85,7 +85,7 @@ export class S3Service {
// return this.run(command);
// }

async uploadObject(name: string, body: any, bucket: string = CALL_AWS_S3_BUCKET): Promise<PutObjectCommandOutput> {
async uploadObject(name: string, body: any, bucket: string = CALL_S3_BUCKET): Promise<PutObjectCommandOutput> {
try {
const command = new PutObjectCommand({
Bucket: bucket,
Expand All @@ -104,7 +104,7 @@ export class S3Service {
}
}

async deleteObject(name: string, bucket: string = CALL_AWS_S3_BUCKET): Promise<DeleteObjectCommandOutput> {
async deleteObject(name: string, bucket: string = CALL_S3_BUCKET): Promise<DeleteObjectCommandOutput> {
try {
this.logger.info(`Deleting object in S3: ${name}`);
const command = new DeleteObjectCommand({ Bucket: bucket, Key: name });
Expand All @@ -115,7 +115,7 @@ export class S3Service {
}
}

async deleteFolder(folderName: string, bucket: string = CALL_AWS_S3_BUCKET) {
async deleteFolder(folderName: string, bucket: string = CALL_S3_BUCKET) {
try {
const listParams = {
Bucket: bucket,
Expand Down Expand Up @@ -159,7 +159,7 @@ export class S3Service {
async listObjects(
subbucket = '',
searchPattern = '',
bucket: string = CALL_AWS_S3_BUCKET,
bucket: string = CALL_S3_BUCKET,
maxObjects = 20,
continuationToken?: string
): Promise<ListObjectsV2CommandOutput> {
Expand Down Expand Up @@ -193,7 +193,7 @@ export class S3Service {
}
}

async getObjectAsJson(name: string, bucket: string = CALL_AWS_S3_BUCKET): Promise<Object | undefined> {
async getObjectAsJson(name: string, bucket: string = CALL_S3_BUCKET): Promise<Object | undefined> {
try {
const obj = await this.getObject(name, bucket);
const str = await obj.Body?.transformToString();
Expand All @@ -213,7 +213,7 @@ export class S3Service {
}
}

async getObjectAsStream(name: string, bucket: string = CALL_AWS_S3_BUCKET, range?: { start: number; end: number }) {
async getObjectAsStream(name: string, bucket: string = CALL_S3_BUCKET, range?: { start: number; end: number }) {
try {
const obj = await this.getObject(name, bucket, range);

Expand All @@ -233,7 +233,7 @@ export class S3Service {
}
}

async getHeaderObject(name: string, bucket: string = CALL_AWS_S3_BUCKET): Promise<HeadObjectCommandOutput> {
async getHeaderObject(name: string, bucket: string = CALL_S3_BUCKET): Promise<HeadObjectCommandOutput> {
try {
const headParams: HeadObjectCommand = new HeadObjectCommand({
Bucket: bucket,
Expand Down Expand Up @@ -276,7 +276,7 @@ export class S3Service {

private async getObject(
name: string,
bucket: string = CALL_AWS_S3_BUCKET,
bucket: string = CALL_S3_BUCKET,
range?: { start: number; end: number }
): Promise<GetObjectCommandOutput> {
const command = new GetObjectCommand({
Expand Down

0 comments on commit ef3098b

Please sign in to comment.