const db = require('../db') const sendgrid = require('@sendgrid/mail') sendgrid.setApiKey(process.env.SENDGRID_KEY) const email = module.exports = {} email.sendAccountConfirmation = async user => { const confirmUrl = await db.user.createLoginLink(user.uuid) const msg = { to: user.email, from: {email: 'registration@email.societyofsocks.us', name: 'Society of Socks'}, templateId: 'd-33407f1dd1b14b7b84dd779511039c95', dynamic_template_data: { confirmUrl: confirmUrl } }; await sendgrid.send(msg); } email.sendPasswordReset = async user => { const resetURL = await db.user.createPasswordReset(user.uuid) const msg = { to: user.email, from: {email: 'accounts@email.societyofsocks.us', name: 'Society of Socks'}, templateId: 'd-90d751cfc8cd4047be39c994ff9d0f5c', dynamic_template_data: { resetPasswordURL: resetURL } } await sendgrid.send(msg) }