diff --git a/server/server.tsx b/server/server.tsx index 3930e9a..9b0c838 100644 --- a/server/server.tsx +++ b/server/server.tsx @@ -8,12 +8,19 @@ import { EirikLd } from '../src/ld'; import { ContactFormData } from '../src/types'; import { Resend } from 'resend'; +const missingEnvVars:Array = []; +for (const envVar of ['RESEND_API_KEY','RESEND_TO_EMAIL','RESEND_FROM_EMAIL']){ + if (!process.env[envVar]){ + missingEnvVars.push(envVar); + } +} +if (missingEnvVars.length){ + throw new Error(`Missing env vars [ ${missingEnvVars.join(', ')} ]`); +} + const resend = new Resend(process.env['RESEND_API_KEY']); const toMail = process.env['RESEND_TO_EMAIL']; const fromMail = process.env['RESEND_FROM_EMAIL']; -if (!toMail||!fromMail){ - throw new Error("Incomplete mail config"); -} const PORT = process.env.PORT || 3000; const app = express();