Skip to content

Commit

Permalink
enhance err mssg
Browse files Browse the repository at this point in the history
  • Loading branch information
ekulno committed Jul 21, 2024
1 parent b115fe5 commit 39a1394
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions server/server.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,19 @@ import { EirikLd } from '../src/ld';
import { ContactFormData } from '../src/types';
import { Resend } from 'resend';

const missingEnvVars:Array<string> = [];
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();
Expand Down

0 comments on commit 39a1394

Please sign in to comment.