From 4d82639162ad59b34e64c40426766da2d390c089 Mon Sep 17 00:00:00 2001 From: Victor Zheng <36215359+victorzheng02@users.noreply.github.com> Date: Wed, 13 Mar 2024 21:06:07 -0700 Subject: [PATCH] prefix env vars (#189) In preparation to load the secrets into the wato infra config --- backend/emails/emails.js | 8 ++++---- backend/routes/files.routes.js | 2 +- backend/server.js | 4 ++-- backend/service/files.service.js | 4 ++-- backend/service/sendEmail.js | 6 +++--- backend/utils/seedData.js | 3 ++- frontend/src/axiosConfig.js | 2 +- frontend/src/contexts/AuthContext.js | 2 +- frontend/src/firebase.js | 12 ++++++------ 9 files changed, 22 insertions(+), 21 deletions(-) diff --git a/backend/emails/emails.js b/backend/emails/emails.js index 43fd076..9f96882 100644 --- a/backend/emails/emails.js +++ b/backend/emails/emails.js @@ -16,7 +16,7 @@ const currencyFormatter = new Intl.NumberFormat('en-CA', { const getEmailToSection = async (reporter_id, recipients) => { const emailToSet = new Set( - process.env.EMAIL_RECIPIENTS?.split(',') || [ + process.env.WATO_FINANCE_EMAIL_RECIPIENTS?.split(',') || [ 'jw4he@watonomous.ca', 'v2zheng@watonomous.ca', 'william.li@watonomous.ca', @@ -42,7 +42,7 @@ const getEmailToSection = async (reporter_id, recipients) => { } if (recipients.includes(EMAIL_RECIPIENTS.finance)) { - // emailToSet.add(process.env.FINANCE_EMAIL) + // emailToSet.add(process.env.WATO_FINANCE_FINANCE_EMAIL) } if (recipients.includes(EMAIL_RECIPIENTS.reporter)) { @@ -122,9 +122,9 @@ const getTicketLinkHTML = (ticketPath) => `

View the ticket here: - ${process.env.CLIENT_URL}${ticketPath} + ${process.env.WATO_FINANCE_CLIENT_URL}${ticketPath}

` diff --git a/backend/routes/files.routes.js b/backend/routes/files.routes.js index 2436919..3cf4f92 100644 --- a/backend/routes/files.routes.js +++ b/backend/routes/files.routes.js @@ -8,7 +8,7 @@ const upload = multer({ storage: multerS3({ s3: s3Client, contentType: multerS3.AUTO_CONTENT_TYPE, - bucket: process.env.AWS_FINANCE_BUCKET_NAME, + bucket: process.env.WATO_FINANCE_AWS_FINANCE_BUCKET_NAME, storageClass: 'STANDARD_IA', metadata: function (req, file, cb) { cb(null, { diff --git a/backend/server.js b/backend/server.js index 67c4b78..d033482 100644 --- a/backend/server.js +++ b/backend/server.js @@ -6,12 +6,12 @@ const mongoose = require('mongoose') require('dotenv').config() const app = express() -const port = process.env.PORT || 5000 +const port = process.env.WATO_FINANCE_PORT || 5000 app.use(cors()) app.use(express.json()) -const uri = process.env.ATLAS_URI +const uri = process.env.WATO_FINANCE_ATLAS_URI mongoose.connect(uri, { useNewUrlParser: true, useUnifiedTopology: true, diff --git a/backend/service/files.service.js b/backend/service/files.service.js index 10284dc..4086c65 100644 --- a/backend/service/files.service.js +++ b/backend/service/files.service.js @@ -16,7 +16,7 @@ const getAllFilesByReference = async (reference) => { files.map(async (file) => { // generate a presigned url for each file const presignedUrl = await generatePresignedUrl( - process.env.AWS_FINANCE_BUCKET_NAME, + process.env.WATO_FINANCE_AWS_FINANCE_BUCKET_NAME, getS3FileKey(file.reference_code, file.name) ) return { @@ -78,7 +78,7 @@ const deleteFile = async (referenceCode, fileName) => { // first delete from s3 first, as its ok to have orphaned files in mongo (no cost) since we only store metadata // then delete from db await deleteS3File( - process.env.AWS_FINANCE_BUCKET_NAME, + process.env.WATO_FINANCE_AWS_FINANCE_BUCKET_NAME, getS3FileKey(referenceCode, fileName) ) return File.findOneAndDelete({ diff --git a/backend/service/sendEmail.js b/backend/service/sendEmail.js index 580ddcf..a98634b 100644 --- a/backend/service/sendEmail.js +++ b/backend/service/sendEmail.js @@ -1,8 +1,8 @@ const Mailjet = require('node-mailjet') const mailjet = Mailjet.apiConnect( - process.env.MAILJET_API_KEY, - process.env.MAILJET_SECRET_KEY + process.env.WATO_FINANCE_MAILJET_API_KEY, + process.env.WATO_FINANCE_MAILJET_SECRET_KEY ) const sendEmail = async ({ To, Subject, HTMLPart }) => { @@ -11,7 +11,7 @@ const sendEmail = async ({ To, Subject, HTMLPart }) => { Messages: [ { From: { - Email: process.env.FINANCE_EMAIL, + Email: process.env.WATO_FINANCE_FINANCE_EMAIL, }, To, Subject, diff --git a/backend/utils/seedData.js b/backend/utils/seedData.js index ea27c3a..7de2966 100644 --- a/backend/utils/seedData.js +++ b/backend/utils/seedData.js @@ -13,7 +13,8 @@ const numFundingItemsToCreatePerSponsorshipFund = 2 const numPersonalPurchasesToCreatePerFundingItem = 2 const numUWFinancePurchasesToCreatePerFundingItem = 2 -const backend_url = process.env.BACKEND_URL || 'http://localhost:5000' +const backend_url = + process.env.WATO_FINANCE_BACKEND_URL || 'http://localhost:5000' const lorem = new LoremIpsum({ wordsPerSentence: { diff --git a/frontend/src/axiosConfig.js b/frontend/src/axiosConfig.js index 73afd06..d07da4f 100644 --- a/frontend/src/axiosConfig.js +++ b/frontend/src/axiosConfig.js @@ -2,7 +2,7 @@ import axios from 'axios' import app from './firebase' import { getAuth } from 'firebase/auth' export const axiosPreset = axios.create({ - baseURL: `${process.env.REACT_APP_BACKEND_URL}`, + baseURL: `${process.env.REACT_APP_WATO_FINANCE_BACKEND_URL}`, }) // dont have access to currentuser at axiosPreset creation, so append on at request time diff --git a/frontend/src/contexts/AuthContext.js b/frontend/src/contexts/AuthContext.js index 3c7f79e..3c582b0 100644 --- a/frontend/src/contexts/AuthContext.js +++ b/frontend/src/contexts/AuthContext.js @@ -74,7 +74,7 @@ export const AuthProvider = ({ children }) => { const identifier = searchWithEmail ? userEmail : userWatiam const retrievedGroup = await axiosPreset.get( - `${process.env.REACT_APP_BACKEND_URL}/googlegroups/${identifier}` + `${process.env.REACT_APP_WATO_FINANCE_BACKEND_URL}/googlegroups/${identifier}` ) setCurrentUserGroup(retrievedGroup?.data?.title) diff --git a/frontend/src/firebase.js b/frontend/src/firebase.js index 5ce3208..0f810fd 100644 --- a/frontend/src/firebase.js +++ b/frontend/src/firebase.js @@ -1,12 +1,12 @@ import { initializeApp } from 'firebase/app' const firebaseConfig = { - apiKey: process.env.REACT_APP_API_KEY, - authDomain: process.env.REACT_APP_AUTH_DOMAIN, - projectId: process.env.REACT_APP_PROJECT_ID, - storageBucket: process.env.REACT_APP_STORAGE_BUCKET, - messagingSenderId: process.env.REACT_APP_MESSAGING_SENDER_ID, - appId: process.env.REACT_APP_APP_ID, + apiKey: process.env.REACT_APP_WATO_FINANCE_API_KEY, + authDomain: process.env.REACT_APP_WATO_FINANCE_AUTH_DOMAIN, + projectId: process.env.REACT_APP_WATO_FINANCE_PROJECT_ID, + storageBucket: process.env.REACT_APP_WATO_FINANCE_STORAGE_BUCKET, + messagingSenderId: process.env.REACT_APP_WATO_FINANCE_MESSAGING_SENDER_ID, + appId: process.env.REACT_APP_WATO_FINANCE_APP_ID, } const app = initializeApp(firebaseConfig)