mirror of
https://github.com/aaronpo97/the-biergarten-app.git
synced 2026-02-16 20:13:49 +00:00
Add environment variable validation and parsing
Adds a validation schema for the application's environment variables using the Zod library. The parsed environment variables are then exported as constants that can be imported throughout the application, replacing the direct use of process.env.
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
import { SPARKPOST_SENDER_ADDRESS } from '../env';
|
||||
import client from './client';
|
||||
|
||||
interface EmailParams {
|
||||
@@ -7,12 +8,6 @@ interface EmailParams {
|
||||
subject: string;
|
||||
}
|
||||
|
||||
const { SPARKPOST_SENDER_ADDRESS } = process.env;
|
||||
|
||||
if (!SPARKPOST_SENDER_ADDRESS) {
|
||||
throw new Error('SPARKPOST_SENDER_ADDRESS env variable is not set.');
|
||||
}
|
||||
|
||||
const sendEmail = async ({ address, text, html, subject }: EmailParams) => {
|
||||
const from = SPARKPOST_SENDER_ADDRESS;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user