"use strict";(()=>{var e={};e.id=7402,e.ids=[7402],e.modules={76102:e=>{e.exports=require("@moduletrace/datasquirel/dist/client")},39383:e=>{e.exports=require("@moduletrace/datasquirel/dist/package-shared/actions/users/user-auth")},65967:e=>{e.exports=require("@moduletrace/datasquirel/dist/package-shared/utils/ejson")},93726:e=>{e.exports=require("@moduletrace/datasquirel/dist/package-shared/utils/numberfy")},30889:e=>{e.exports=require("@moduletrace/datasquirel/dist/package-shared/utils/slugify")},75600:e=>{e.exports=require("next/dist/compiled/next-server/pages-api.runtime.prod.js")},79646:e=>{e.exports=require("child_process")},29021:e=>{e.exports=require("fs")},21820:e=>{e.exports=require("os")},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}}})},87476:(e,r,t)=>{t.r(r),t.d(r,{config:()=>E,default:()=>f,routeModule:()=>D});var s={};t.r(s),t.d(s,{default:()=>m});var n=t(89947),a=t(2706),i=t(96762),o=t(29021),l=t.n(o),u=t(21820),d=t.n(u),c=t(79646),p=t(67619);async function S({dbName:e,user:r,res:t}){let s=d().platform().match(/win/i)?"'C:\\Program Files\\MySQL\\MySQL Server 8.0\\bin\\mysqldump.exe'":"mysqldump";try{let n={cwd:process.cwd()},a=`${process.env.DSQL_USER_DB_SCHEMA_PATH}/user-${r.id}/export.sql`;d().platform().match(/win/i)&&(n.shell="bash.exe");let i=`${s} -u ${process.env.DSQL_DB_USERNAME} -h ${process.env.DSQL_DB_HOST} -p${process.env.DSQL_DB_PASSWORD} ${e} > ${a}`;(0,c.execSync)(i,n),t.setHeader("Content-Type","application/zip"),t.setHeader("Content-Disposition","attachment; filename=export.sql"),l().createReadStream(a).pipe(t)}catch(e){(0,p.A)({component:"/functions/backend/exportDb/lines-30-46",message:e.message,user:r})}}var _=t(69842);async function m(e,r){if("GET"!==e.method)return r.json({msg:"Failed!"});let{user:t}=await (0,_.A)(e,r,!0);if(!t)return r.json({success:!1,msg:"Unauthorized"});let{dbName:s}=e.query;await S({dbName:s?.toString()||"",res:r,user:t}),r.json({success:!0})}let f=(0,i.M)(s,"default"),E=(0,i.M)(s,"config"),D=new n.PagesAPIRouteModule({definition:{kind:a.A.PAGES_API,page:"/api/exportDatabase",pathname:"/api/exportDatabase",bundlePath:"",filename:""},userland:s})},55153:(e,r,t)=>{t.d(r,{On:()=>n.a,_n:()=>i}),t(76102);var s=t(65967),n=t.n(s);t(30889);var a=t(93726);let i=t.n(a)()},69842:(e,r,t)=>{t.d(r,{A:()=>i});var s=t(39383),n=t.n(s),a=t(55153);async function i(e,r,t,s){let i=n()({req:e,level:t?"deep":void 0}),o={DSQL_REMOTE_SQL_HOST:process.env.DSQL_REMOTE_SQL_HOST,DSQL_SU_USER_ID:process.env.DSQL_SU_USER_ID,DSQL_HOST_ENV:process.env.DSQL_HOST_ENV,DSQL_HOST:process.env.DSQL_HOST,DSQL_STATIC_HOST:process.env.DSQL_STATIC_HOST,DSQL_GOOGLE_CLIENT_ID:process.env.DSQL_GOOGLE_CLIENT_ID,DSQL_TINY_MCE_API_KEY:process.env.DSQL_TINY_MCE_API_KEY};return s&&i.payload?.id&&(0,a._n)(process.env.DSQL_SU_USER_ID)!==i.payload.id?{user:null,appData:o}:{user:i.payload,appData:o}}},67619:(e,r,t)=>{t.d(r,{A:()=>a});var s=t(29021),n=t.n(s);async function a({user:e,message:r,component:t,noMail:s,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"],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 s=`🚀 SERVER ERROR ===========================
Error Message: ${r}
Component: ${t}`;e?.id&&e?.first_name&&e?.last_name&&e?.email&&(s+=`
User Id: ${e?.id}
User Name: ${e?.first_name} ${e?.last_name}
User Email: ${e?.email}`),a?.url&&(s+=`
URL: ${a.url}`),a?.body&&(s+=`
Request Body: ${JSON.stringify(a.body,null,4)}`),o&&(s+=`
IP: ${o}`),s+=`
Date: ${i.toDateString()}
========================================`,n().existsSync("./.tmp/error.log")||n().writeFileSync("./.tmp/error.log","","utf-8");let l=n().readFileSync("./.tmp/error.log","utf-8");n().writeFileSync("./.tmp/error.log",s),n().appendFileSync("./.tmp/error.log",`




${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=87476);module.exports=t})();