19 lines
3.8 KiB
JavaScript
19 lines
3.8 KiB
JavaScript
"use strict";(()=>{var e={};e.id=3409,e.ids=[3409],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")},81630:e=>{e.exports=require("http")},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}}})},93987:(e,r,t)=>{t.r(r),t.d(r,{config:()=>p,default:()=>m,routeModule:()=>f});var s={};t.r(s),t.d(s,{default:()=>d});var n=t(89947),a=t(2706),o=t(96762),i=t(79531),l=t.n(i),c=t(77538),u=t.n(c);async function d(e,r){if("POST"!==e.method)return r.json({msg:"Failed!"});let{name:t,email:s,message:n}=e.body;if(!s.match(/.*@.*\..*/))return r.json({success:!1,msg:"Invalid Email"});if(!t.match(/./)||!n.match(/./))return r.json({success:!1,msg:"Please Fill in all Fields"});try{(await l()({to:process.env.DSQL_CONTACT_EMAIL,html:`
|
|
<h2>Message From ${t}, ${s}</h2>
|
|
<p>${n}</p>
|
|
`,subject:"Contact Form Submission",text:`Message from ${t}, ${s}`})).messageId?r.json({success:!0}):r.json({success:!1,msg:"Message Sending Failed"})}catch(e){u()({component:"/api/contact/main-catch-error",message:e.message}),r.json({success:!1,msg:"Database Files could not be written!"})}}let m=(0,o.M)(s,"default"),p=(0,o.M)(s,"config"),f=new n.PagesAPIRouteModule({definition:{kind:a.A.PAGES_API,page:"/api/contact",pathname:"/api/contact",bundlePath:"",filename:""},userland:s})},79531:(e,r,t)=>{let s=t(29021),n=t(21572).createTransport({host:process.env.DSQL_MAIL_HOST,port:465,secure:!0,auth:{user:process.env.DSQL_MAIL_EMAIL,pass:process.env.DSQL_MAIL_PASSWORD}});e.exports=async function({to:e,subject:r,text:t,html:a,alias:o}){let i;if(!process.env.DSQL_MAIL_HOST||!process.env.DSQL_MAIL_EMAIL||!process.env.DSQL_MAIL_PASSWORD)return null;let l=(o?.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}}/,a||"").replace(/{{issue_date}}/,Date().substring(0,24));try{let s={};s.from=`"Datasquirel" <${l}>`,s.sender=l,o&&(s["replyTo "]=l),s.to=e,s.subject=r,s.text=t,s.html=c,i=await n.sendMail(s)}catch(e){console.log("ERROR in handleNodemailer Function =>",e.message)}return i}},77538:(e,r,t)=>{let s=t(29021),{IncomingMessage:n}=t(81630);e.exports=async function({user:e,message:r,component:t,noMail:n,req:a}){let o=new Date,i=(()=>{if(!a)return null;try{let e=a.headers["x-forwarded-for"],r=a.headers["x-real-ip"],t=a.headers["cf-connecting-ip"],s=Array.isArray(e)?e[0]:e?.split(",")[0],n=t||s||r||a.socket.remoteAddress;if(!n)return null;return String(n)}catch(e){return null}})();try{let n=`🚀 SERVER ERROR ===========================
|
|
Error Message: ${r}
|
|
Component: ${t}`;e?.id&&e?.first_name&&e?.last_name&&e?.email&&(n+=`
|
|
User Id: ${e?.id}
|
|
User Name: ${e?.first_name} ${e?.last_name}
|
|
User Email: ${e?.email}`),a?.url&&(n+=`
|
|
URL: ${a.url}`),a?.body&&(n+=`
|
|
Request Body: ${JSON.stringify(a.body,null,4)}`),i&&(n+=`
|
|
IP: ${i}`),n+=`
|
|
Date: ${o.toDateString()}
|
|
========================================`,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",`
|
|
|
|
|
|
|
|
|
|
${l}`)}catch(e){console.log("Server Error Reporting Error:",e.message)}}},2706:(e,r)=>{var t;Object.defineProperty(r,"A",{enumerable:!0,get:function(){return t}}),function(e){e.PAGES="PAGES",e.PAGES_API="PAGES_API",e.APP_PAGE="APP_PAGE",e.APP_ROUTE="APP_ROUTE",e.IMAGE="IMAGE"}(t||(t={}))},89947:(e,r,t)=>{e.exports=t(75600)}};var r=require("../../webpack-api-runtime.js");r.C(e);var t=r(r.s=93987);module.exports=t})(); |