Skip to content

Commit

Permalink
Add SendGrid Verified Sender as a .env var
Browse files Browse the repository at this point in the history
  • Loading branch information
rendall committed Nov 30, 2023
1 parent f120286 commit d06f4ca
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 4 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@
"ts-jest": "^29.1.1",
"ts-loader": "^9.3.0",
"ts-node": "^10.1.0",
"typescript": "^5.1.6",
"typescript": "^5.3.2",
"webpack": "^5.76.0",
"webpack-bundle-analyzer": "^4.9.0",
"webpack-cli": "^4.9.2",
Expand Down
6 changes: 5 additions & 1 deletion src/lib/SendGridNotificationService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ import { config as dotEnvConfig } from "dotenv"
dotEnvConfig()

const _sendGridApiKey = process.env.NOTIFICATION_SERVICE_API_KEY
const sendGridVerifiedSender = process.env.SENDGRID_VERIFIED_SENDER

if (sendGridVerifiedSender === undefined)
throw "SENDGRID_VERIFIED_SENDER is not set in environmental variables"

const _moderatorContactEmails = process.env
.SIMPLE_COMMENT_MODERATOR_CONTACT_EMAIL
Expand Down Expand Up @@ -41,7 +45,7 @@ export class SendGridNotificationService extends AbstractNotificationService {
notifyModerators = async (body: string): Promise<Error | Success> => {
const messages = this._moderatorContactEmails.map(email => ({
to: email,
from: "[email protected]", // Sender's email address
from: sendGridVerifiedSender, // Sender's email address
subject: "Simple Comment Notification",
text: `${body}`,
}))
Expand Down
2 changes: 1 addition & 1 deletion src/tests/backend/SendGridNotificationService.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ jest.mock("dotenv", () => ({
config: jest.fn(() => {
process.env.SIMPLE_COMMENT_MODERATOR_CONTACT_EMAIL =
"[email protected],[email protected],[email protected],[email protected],[email protected],[email protected],[email protected],[email protected],[email protected],[email protected]"

process.env.SENDGRID_VERIFIED_SENDER = "[email protected]"
process.env.NOTIFICATION_SERVICE_API_KEY = "SG.from.test.env"
}),
}))
Expand Down
7 changes: 6 additions & 1 deletion yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -13072,11 +13072,16 @@ typedarray-to-buffer@^3.1.5:
dependencies:
is-typedarray "^1.0.0"

typescript@^5.0.0, typescript@^5.0.4, typescript@^5.1.6:
typescript@^5.0.0, typescript@^5.0.4:
version "5.1.6"
resolved "https://registry.yarnpkg.com/typescript/-/typescript-5.1.6.tgz#02f8ac202b6dad2c0dd5e0913745b47a37998274"
integrity sha512-zaWCozRZ6DLEWAWFrVDz1H6FVXzUSfTy5FUMWsQlU8Ym5JP9eO4xkTIROFCQvhQf61z6O/G6ugw3SgAnvvm+HA==

typescript@^5.3.2:
version "5.3.2"
resolved "https://registry.yarnpkg.com/typescript/-/typescript-5.3.2.tgz#00d1c7c1c46928c5845c1ee8d0cc2791031d4c43"
integrity sha512-6l+RyNy7oAHDfxC4FzSJcz9vnjTKxrLpDG5M2Vu4SHRVNg6xzqZp6LYSR9zjqQTu8DU/f5xwxUdADOkbrIX2gQ==

[email protected]:
version "2.1.5"
resolved "https://registry.yarnpkg.com/uid-safe/-/uid-safe-2.1.5.tgz#2b3d5c7240e8fc2e58f8aa269e5ee49c0857bd3a"
Expand Down

0 comments on commit d06f4ca

Please sign in to comment.