Skip to content

Commit 77a032b

Browse files
committed
fix: set sendMail env vars optional
1 parent f1b9dc9 commit 77a032b

2 files changed

Lines changed: 8 additions & 2 deletions

File tree

src/commands/printEnv.test.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,9 @@ describe('printEnvCommand', () => {
1515
// See : https://stackoverflow.com/questions/56349619/ts2352-declare-object-with-dynamic-properties-and-one-property-with-specific-t
1616
const printEnvCommand = await initPrintEnvCommand({
1717
log,
18-
ENV: { NODE_ENV: NodeEnv.Test },
18+
ENV: {
19+
NODE_ENV: NodeEnv.Test,
20+
},
1921
});
2022
const result = await printEnvCommand({
2123
command: 'whook',

src/services/sendMail.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import { type JsonObject } from 'type-fest';
77
import { YError } from 'yerror';
88

99
export type SendMailEnvVars = {
10-
SMTP_CONNECTION_URL: string;
10+
SMTP_CONNECTION_URL?: string;
1111
};
1212
export type SendMailDependencies = {
1313
ENV: SendMailEnvVars;
@@ -19,6 +19,10 @@ async function initSendMail({
1919
ENV,
2020
log = noop,
2121
}: SendMailDependencies): Promise<SendMailService> {
22+
if (!ENV.SMTP_CONNECTION_URL) {
23+
throw new YError('E_NO_SMTP_URL');
24+
}
25+
2226
const transporter = createTransport({
2327
host: new URL(ENV.SMTP_CONNECTION_URL).hostname,
2428
port: parseInt(new URL(ENV.SMTP_CONNECTION_URL).port, 10),

0 commit comments

Comments
 (0)