created API For Aplication Absensi

This commit is contained in:
2025-10-14 14:08:11 +07:00
commit 96d206d892
56 changed files with 6533 additions and 0 deletions

34
app/config/mail.config.js Normal file
View File

@@ -0,0 +1,34 @@
const nodemailer = require('nodemailer')
require('dotenv').config()
const transporter = nodemailer.createTransport({
host: process.env.MAIL_HOST,
port: process.env.MAIL_PORT,
secure: false, // true for 465, false for other ports
auth: {
user: process.env.MAIL_USERNAME, // Perbaikan di sini
pass: process.env.MAIL_PASSWORD // Perbaikan di sini
},
tls: {
rejectUnauthorized: false // Untuk development, hati-hati di production
}
})
const sendMail = async ({to, subject, html}) => { // Diubah ke object destructuring
try {
await transporter.sendMail({
from: `"${process.env.MAIL_FROM_NAME}" <${process.env.MAIL_FROM_ADDRESS}>`, // Ditambahkan >
to,
subject,
html
})
console.log('Email sent successfully')
} catch (error) {
console.error('Error sending email:', error)
throw error
}
}
module.exports = {
sendMail
}