🧑💻 Improve env variables type safety and management (#718)
Closes #679
This commit is contained in:
@@ -27,7 +27,8 @@
|
||||
"@typebot.io/lib": "workspace:*",
|
||||
"eslint": "8.44.0",
|
||||
"eslint-config-custom": "workspace:*",
|
||||
"@typebot.io/tsconfig": "workspace:*"
|
||||
"@typebot.io/tsconfig": "workspace:*",
|
||||
"@typebot.io/env": "workspace:*"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"@faire/mjml-react": "2.1.4",
|
||||
|
||||
@@ -1,20 +1,20 @@
|
||||
import { createTransport, SendMailOptions } from 'nodemailer'
|
||||
import { env } from '@typebot.io/lib'
|
||||
import { env } from '@typebot.io/env'
|
||||
|
||||
export const sendEmail = (
|
||||
props: Pick<SendMailOptions, 'to' | 'html' | 'subject'>
|
||||
) => {
|
||||
const transporter = createTransport({
|
||||
host: process.env.SMTP_HOST,
|
||||
port: Number(process.env.SMTP_PORT),
|
||||
host: env.SMTP_HOST,
|
||||
port: env.SMTP_PORT,
|
||||
auth: {
|
||||
user: process.env.SMTP_USERNAME,
|
||||
pass: process.env.SMTP_PASSWORD,
|
||||
user: env.SMTP_USERNAME,
|
||||
pass: env.SMTP_PASSWORD,
|
||||
},
|
||||
})
|
||||
|
||||
return transporter.sendMail({
|
||||
from: process.env.SMTP_FROM ?? env('SMTP_FROM'),
|
||||
from: env.NEXT_PUBLIC_SMTP_FROM,
|
||||
...props,
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user