From 6d123f7d90913c1c853d81a2e85f916a1827641d Mon Sep 17 00:00:00 2001 From: sarthakpranesh Date: Sun, 10 Mar 2024 12:42:43 +0530 Subject: [PATCH] chore: reconfiguring for backward comp --- .env | 4 +++- index.ts | 8 ++++---- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/.env b/.env index 1730186..1662b88 100644 --- a/.env +++ b/.env @@ -3,7 +3,9 @@ SERVER_PORT=8001 # you want to use gcp or local filesystem # gcp -> google cloud storage, local -> local filesystem +# defaults to gcp STORAGE_TYPE=local -# if storage type is gcp, then uncomment below and add the bucket name +# if storage type is gcp/not set, then uncomment below and add the bucket name +# defaults to "athene-diagram-files" # STORAGE_GCP_BUCKET_NAME=athene-diagram-files \ No newline at end of file diff --git a/index.ts b/index.ts index 08fc61b..b3d2013 100644 --- a/index.ts +++ b/index.ts @@ -11,14 +11,14 @@ import ShortUniqueId from 'short-unique-id'; import fileStore from './fileStore'; const uid = new ShortUniqueId({ length: 20 }); - const serverPort = parseInt(process.env.SERVER_PORT || '8080'); + let storageBucket: Bucket | typeof fileStore; -if (process.env.STORAGE_TYPE === "gcp") { +if (process.env.STORAGE_TYPE === "local") { + storageBucket = fileStore +} else { const storageClient = new Storage(); storageBucket = storageClient.bucket(process.env.STORAGE_GCP_BUCKET_NAME || 'athene-diagram-files'); -} else { - storageBucket = fileStore } const server = Server.configure({