import nodemailer from "nodemailer"; import { createId } from "@paralleldrive/cuid2"; import { InfisicalClient } from "@infisical/sdk"; const client = new InfisicalClient({ siteUrl: import.meta.env.INFISICAL_URL, auth: { universalAuth: { clientId: import.meta.env.INFISICAL_CLIENTID, clientSecret: import.meta.env.INFISICAL_SECRET, }, }, }); export const POST = async ({ request }) => { try { var secrets = await client.listSecrets({ environment: "dev", projectId: import.meta.env.INFISICAL_PROJECTID, path: "/email", includeImports: false, }); secrets = Object.fromEntries( secrets.map((item) => [item.secretKey, item.secretValue]) ); const thisCuid = createId(); const data = await request.formData(); var message = { from: `${data.get("username")} <${secrets["EMAIL"]}>`, to: `Site Admin <${secrets["RECEIVER"]}>`, subject: `${secrets["EMAIL_HEAD"]} | ${thisCuid}`, text: `---\n${data.get("username")}\n${data.get( "email" )}\n---\n${data.get("message")}`, html: `
---
${data.get("username")}
${data.get(
"email"
)}
---
${data.get("message")}