xtablo-source/api/src/transporter.ts
Arthur Belleville a2de135b11
Fix invite
2025-10-15 16:30:36 +02:00

34 lines
830 B
TypeScript

import { google } from "googleapis";
import nodemailer from "nodemailer";
import { config } from "./config.js";
const OAuth2 = google.auth.OAuth2;
export const createTransporter = () => {
const oauth2Client = new OAuth2(
config.EMAIL_CLIENT_ID,
config.EMAIL_CLIENT_SECRET,
"https://developers.google.com/oauthplayground"
);
oauth2Client.setCredentials({
refresh_token: config.EMAIL_REFRESH_TOKEN,
});
const transporter = nodemailer.createTransport({
host: "smtp.gmail.com",
port: 465,
secure: true,
auth: {
type: "OAuth2",
user: config.EMAIL_USER,
clientId: config.EMAIL_CLIENT_ID,
clientSecret: config.EMAIL_CLIENT_SECRET,
refreshToken: config.EMAIL_REFRESH_TOKEN,
},
});
return transporter;
};
export const transporter = createTransporter();