pull emails from env vars

This commit is contained in:
Thomas Ruoff
2020-10-26 22:59:02 +01:00
parent c55f8f8b3a
commit ef4d9e6ff1

View File

@@ -1,15 +1,18 @@
const SENDGRID_API_KEY = process.env.SENDGRID_API_KEY
const ADMIN_EMAIL = process.env.ADMIN_EMAIL
const FROM_EMAIL = process.env.FROM_EMAIL
const SENDGRID_URL = 'https://api.sendgrid.com/v3/mail/send'
// TODO: move to env
const BOOKING_ADMIN_EMAIL = 'tomru@mail.id0.link'
const FROM_EMAIL = 'pfadibussle@mail.id0.link'
if (!SENDGRID_API_KEY) {
throw new Error('NO SENDGRID_API_KEY set!')
}
if (!SENDGRID_API_KEY) {
throw new Error('NO SENDGRID_API_KEY set!')
if (!ADMIN_EMAIL) {
throw new Error('No ADMIN_EMAIL set!')
}
if (!FROM_EMAIL) {
throw new Error('No FROM_EMAIL set!')
}
async function sendMail(data: object) {
@@ -40,7 +43,7 @@ export async function sendReceivedBookingMail(booking: { uuid: string }) {
const data = {
personalizations: [
{
to: [{ email: BOOKING_ADMIN_EMAIL }],
to: [{ email: ADMIN_EMAIL }],
},
],
from: { email: FROM_EMAIL },