add url helper

This commit is contained in:
Thomas Ruoff
2020-09-16 23:36:11 +02:00
committed by Thomas Ruoff
parent 56c8263e90
commit cd5fa56807
2 changed files with 10 additions and 1 deletions

View File

@@ -1,3 +1,5 @@
import { getBaseURL } from './url'
const SENDGRID_API_KEY = process.env.SENDGRID_API_KEY
const SENDGRID_URL = 'https://api.sendgrid.com/v3/mail/send'
// TODO: move to env
@@ -31,7 +33,7 @@ async function sendMail(data: object) {
function getReceivedBookingText(booking: { uuid: string }) {
return `Hallo lieber Admin,
es ging folgende Buchung ein: https://${process.env.VERCEL_URL}/booking/${booking.uuid}
es ging folgende Buchung ein: {getBaseURL()}/booking/${booking.uuid}
MfG`
}

7
helpers/url.ts Normal file
View File

@@ -0,0 +1,7 @@
const URL = process.env.VERCEL_URL
? `https://${process.env.VERCEL_URL}`
: 'http://localhost:3000'
export function getBaseURL(): string {
return URL
}