dsql-admin/dsql-app/.local_dist/server/pages/api/test/mail.js

16 lines
3.5 KiB
JavaScript
Raw Normal View History

2025-01-14 06:42:13 +00:00
"use strict";(()=>{var e={};e.id=5116,e.ids=[5116],e.modules={75600:e=>{e.exports=require("next/dist/compiled/next-server/pages-api.runtime.prod.js")},21572:e=>{e.exports=require("nodemailer")},29021:e=>{e.exports=require("fs")},96762:(e,r)=>{Object.defineProperty(r,"M",{enumerable:!0,get:function(){return function e(r,t){return t in r?r[t]:"then"in r&&"function"==typeof r.then?r.then(r=>e(r,t)):"function"==typeof r&&"default"===t?r:void 0}}})},5068:(e,r,t)=>{t.r(r),t.d(r,{config:()=>d,default:()=>c,routeModule:()=>p});var n={};t.r(n),t.d(n,{default:()=>u});var s=t(89947),a=t(2706),i=t(96762),o=t(96052),l=t(67619);async function u(e,r){if("GET"!==e.method)return r.json({msg:"Failed!"});try{await (0,o.A)({alias:"support",html:"<h1>Test Mail</h1><p>Hi there DSQL. Firing up on all systems now.</p>",subject:"Test Mail",text:"Test Mail",to:"dexomediaorg@gmail.com"}),r.json({success:!0})}catch(e){(0,l.A)({component:"/api/addUserMedia/catch-error",message:e.message}),r.json({success:!1,msg:"Database Files could not be written!"})}}let c=(0,i.M)(n,"default"),d=(0,i.M)(n,"config"),p=new s.PagesAPIRouteModule({definition:{kind:a.A.PAGES_API,page:"/api/test/mail",pathname:"/api/test/mail",bundlePath:"",filename:""},userland:n})},96052:(e,r,t)=>{t.d(r,{A:()=>o});var n=t(29021),s=t.n(n),a=t(21572);let i=t.n(a)().createTransport({host:process.env.DSQL_MAIL_HOST,port:465,secure:!0,auth:{user:process.env.DSQL_MAIL_EMAIL,pass:process.env.DSQL_MAIL_PASSWORD}});async function o({to:e,subject:r,text:t,html:n,alias:a,senderName:o}){let l;if(!process.env.DSQL_MAIL_HOST||!process.env.DSQL_MAIL_EMAIL||!process.env.DSQL_MAIL_PASSWORD)return null;let u=(a?.match(/support/i),process.env.DSQL_MAIL_EMAIL);if(!s().existsSync("./email/index.html"))return;let c=s().readFileSync("./email/index.html","utf8").replace(/{{email_body}}/,n||"").replace(/{{issue_date}}/,Date().substring(0,24));try{let n={};n.from=`"${o||"Datasquirel"}" <${u}>`,n.sender=u,a&&(n.replyTo=u),n.to=e,n.subject=r,n.text=t,n.html=c,l=await i.sendMail(n)}catch(e){console.log("ERROR in handleNodemailer Function =>",e.message)}return l}},67619:(e,r,t)=>{t.d(r,{A:()=>a});var n=t(29021),s=t.n(n);async function a({user:e,message:r,component:t,noMail:n,req:a}){let i=new Date,o=(()=>{if(!a)return null;try{let e=a.headers["x-forwarded-for"],r=a.headers["x-real-ip"],t=a.headers["cf-connecting-ip"],n=Array.isArray(e)?e[0]:e?.split(",")[0],s=t||n||r||a.socket.remoteAddress;if(!s)return null;return String(s)}catch(e){return null}})();try{let n=`🚀 SERVER ERROR ===========================
2024-12-08 19:56:57 +00:00
Error Message: ${r}
2025-01-13 08:00:21 +00:00
Component: ${t}`;e?.id&&e?.first_name&&e?.last_name&&e?.email&&(n+=`
2024-12-08 19:56:57 +00:00
User Id: ${e?.id}
User Name: ${e?.first_name} ${e?.last_name}
2025-01-13 08:00:21 +00:00
User Email: ${e?.email}`),a?.url&&(n+=`
URL: ${a.url}`),a?.body&&(n+=`
Request Body: ${JSON.stringify(a.body,null,4)}`),o&&(n+=`
IP: ${o}`),n+=`
2024-12-08 19:56:57 +00:00
Date: ${i.toDateString()}
2025-01-13 08:00:21 +00:00
========================================`,s().existsSync("./.tmp/error.log")||s().writeFileSync("./.tmp/error.log","","utf-8");let l=s().readFileSync("./.tmp/error.log","utf-8");s().writeFileSync("./.tmp/error.log",n),s().appendFileSync("./.tmp/error.log",`
2024-12-08 19:56:57 +00:00
2025-01-13 08:00:21 +00:00
${l}`)}catch(e){console.log("Server Error Reporting Error:",e.message)}}},2706:(e,r)=>{Object.defineProperty(r,"A",{enumerable:!0,get:function(){return t}});var t=function(e){return e.PAGES="PAGES",e.PAGES_API="PAGES_API",e.APP_PAGE="APP_PAGE",e.APP_ROUTE="APP_ROUTE",e.IMAGE="IMAGE",e}({})},89947:(e,r,t)=>{e.exports=t(75600)}};var r=require("../../../webpack-api-runtime.js");r.C(e);var t=r(r.s=5068);module.exports=t})();