🎥 Make videos programmatically with React
add checking of environment
Alex Fernandez50e49c4255b3
diff --git a/packages/cloudrun/src/api/helpers/get-auth-client-for-url.ts b/packages/cloudrun/src/api/helpers/get-auth-client-for-url.tsindex 4ef0577e58..9b4f44ffa8 100644--- a/packages/cloudrun/src/api/helpers/get-auth-client-for-url.ts+++ b/packages/cloudrun/src/api/helpers/get-auth-client-for-url.ts@@ -1,12 +1,21 @@import {GoogleAuth} from 'google-auth-library';export const getAuthClientForUrl = async (url: string) => {- const auth = new GoogleAuth({- credentials: {- client_email: process.env.REMOTION_GCP_CLIENT_EMAIL,- private_key: process.env.REMOTION_GCP_PRIVATE_KEY,- },- });+ let auth = null;+ if (+ process.env.REMOTION_GCP_CLIENT_EMAIL &&+ process.env.REMOTION_GCP_PRIVATE_KEY+ ) {+ auth = new GoogleAuth({+ credentials: {+ client_email: process.env.REMOTION_GCP_CLIENT_EMAIL,+ private_key: process.env.REMOTION_GCP_PRIVATE_KEY,+ },+ });+ } else {+ auth = new GoogleAuth();+ }+const client = await auth.getIdTokenClient(url);return client;};diff --git a/packages/cloudrun/src/api/helpers/get-cloud-logging-client.ts b/packages/cloudrun/src/api/helpers/get-cloud-logging-client.tsindex cea161b046..39289384ba 100644--- a/packages/cloudrun/src/api/helpers/get-cloud-logging-client.ts+++ b/packages/cloudrun/src/api/helpers/get-cloud-logging-client.ts@@ -3,11 +3,19 @@ import {v2} from '@google-cloud/logging';const {LoggingServiceV2Client} = v2;export const getCloudLoggingClient = () => {- return new LoggingServiceV2Client({- projectId: process.env.REMOTION_GCP_PROJECT_ID,- credentials: {- client_email: process.env.REMOTION_GCP_CLIENT_EMAIL,- private_key: process.env.REMOTION_GCP_PRIVATE_KEY,- },- });+ if (+ process.env.REMOTION_GCP_PROJECT_ID &&+ process.env.REMOTION_GCP_CLIENT_EMAIL &&+ process.env.REMOTION_GCP_PRIVATE_KEY+ ) {+ return new LoggingServiceV2Client({+ projectId: process.env.REMOTION_GCP_PROJECT_ID,+ credentials: {+ client_email: process.env.REMOTION_GCP_CLIENT_EMAIL,+ private_key: process.env.REMOTION_GCP_PRIVATE_KEY,+ },+ });+ }++ return new LoggingServiceV2Client();};diff --git a/packages/cloudrun/src/api/helpers/get-cloud-storage-client.ts b/packages/cloudrun/src/api/helpers/get-cloud-storage-client.tsindex b4edf940a4..96d1fb0015 100644--- a/packages/cloudrun/src/api/helpers/get-cloud-storage-client.ts+++ b/packages/cloudrun/src/api/helpers/get-cloud-storage-client.ts@@ -1,11 +1,19 @@import {Storage} from '@google-cloud/storage';export const getCloudStorageClient = () => {- return new Storage({- projectId: process.env.REMOTION_GCP_PROJECT_ID,- credentials: {- client_email: process.env.REMOTION_GCP_CLIENT_EMAIL,- private_key: process.env.REMOTION_GCP_PRIVATE_KEY,- },- });+ if (+ process.env.REMOTION_GCP_PROJECT_ID &&+ process.env.REMOTION_GCP_CLIENT_EMAIL &&+ process.env.REMOTION_GCP_PRIVATE_KEY+ ) {+ return new Storage({+ projectId: process.env.REMOTION_GCP_PROJECT_ID,+ credentials: {+ client_email: process.env.REMOTION_GCP_CLIENT_EMAIL,+ private_key: process.env.REMOTION_GCP_PRIVATE_KEY,+ },+ });+ }++ return new Storage();};diff --git a/packages/cloudrun/src/api/helpers/get-resource-manager-client.ts b/packages/cloudrun/src/api/helpers/get-resource-manager-client.tsindex daf8c8ac5c..bdd4c77c94 100644--- a/packages/cloudrun/src/api/helpers/get-resource-manager-client.ts+++ b/packages/cloudrun/src/api/helpers/get-resource-manager-client.ts@@ -2,11 +2,19 @@ import {v3} from '@google-cloud/resource-manager';const {ProjectsClient} = v3;export const getResourceManagerClient = () => {- return new ProjectsClient({- projectId: process.env.REMOTION_GCP_PROJECT_ID,- credentials: {- client_email: process.env.REMOTION_GCP_CLIENT_EMAIL,- private_key: process.env.REMOTION_GCP_PRIVATE_KEY,- },- });+ if (+ process.env.REMOTION_GCP_PROJECT_ID &&+ process.env.REMOTION_GCP_CLIENT_EMAIL &&+ process.env.REMOTION_GCP_PRIVATE_KEY+ ) {+ return new ProjectsClient({+ projectId: process.env.REMOTION_GCP_PROJECT_ID,+ credentials: {+ client_email: process.env.REMOTION_GCP_CLIENT_EMAIL,+ private_key: process.env.REMOTION_GCP_PRIVATE_KEY,+ },+ });+ }++ return new ProjectsClient();};