Skip to content

Commit

Permalink
configure env to use dotenv package
Browse files Browse the repository at this point in the history
  • Loading branch information
Lyton505 committed Nov 3, 2024
1 parent a8b011d commit b7188ba
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 15 deletions.
18 changes: 9 additions & 9 deletions api/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion api/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
"devDependencies": {
"@types/cors": "^2.8.17",
"@types/express": "^4.17.21",
"@types/node": "^22.5.4",
"@types/node": "^22.8.1",
"@types/uuid": "^10.0.0",
"body-parser": "^1.20.3",
"prettier": "^3.3.3",
Expand Down
6 changes: 3 additions & 3 deletions api/src/routes/user.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,15 @@ router.post("/test", async (req: any, res: any) => {

router.post("/send-email", async (req: any, res: any) => {
try {
const { email, name } = req.body;

const SENDGRID_API_KEY = process.env.SEND_GRID_API_KEY || "";
const SEND_GRID_TEST_EMAIL = process.env.SEND_GRID_TEST_EMAIL || "";

if (SENDGRID_API_KEY === "" || SEND_GRID_TEST_EMAIL === "") {
throw new Error("SendGrid API key or test email is missing");
throw new Error("SendGrid API key or test email is missing");
}

const { email, name } = req.body;

sgMail.setApiKey(SENDGRID_API_KEY);

await sgMail.send({
Expand Down
4 changes: 2 additions & 2 deletions api/src/server.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import express from "express"
import express from "express";
import bodyParser from "body-parser"
import connectDB from "./config/db"
import connectDB from "./config/db";

import * as routes from "./routes/index"

Expand Down

0 comments on commit b7188ba

Please sign in to comment.