dsql-admin/dsql-app/.local_dist/server/pages/api/connect/verify.js

16 lines
4.2 KiB
JavaScript
Raw Normal View History

2025-01-14 15:27:08 +00:00
"use strict";(()=>{var e={};e.id=3033,e.ids=[3033],e.modules={39908:e=>{e.exports=require("@moduletrace/datasquirel/dist/users/user-auth")},75600:e=>{e.exports=require("next/dist/compiled/next-server/pages-api.runtime.prod.js")},29021:e=>{e.exports=require("fs")},55591:e=>{e.exports=require("https")},79551:e=>{e.exports=require("url")},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}}})},77666:(e,r,t)=>{t.r(r),t.d(r,{config:()=>m,default:()=>p,routeModule:()=>f});var n={};t.r(n),t.d(n,{default:()=>d});var o=t(89947),s=t(2706),a=t(96762),i=t(79551),l=t(64166),u=t(67619),c=t(69842);async function d(e,r){if("POST"!==e.method)return r.json({msg:"Failed!"});let t=await (0,c.A)(e,r,!0);if(!t)return r.json({success:!1,msg:"Unauthorized"});let{url:n,key:o,database:s,dbSchema:a,type:d}=e.body;try{let{hostname:e,port:t,protocol:s}=new i.URL(n),a=await (0,l.A)({scheme:s,headers:{Authorization:o},hostname:e,port:t,path:"/api/connect",method:"POST",body:{url:n,key:o}}),u=JSON.parse(a);if(!u?.success)throw Error(u.msg||"Remote request failed");r.json({success:!0,payload:u.payload})}catch(e){console.log("Connect Verification Initialtor Error, =>",e.message),(0,u.A)({component:"/api/connect/verify/main-catch-error",message:e.message,user:t}),r.json({success:!1,msg:"Operation Failed!"})}}let p=(0,a.M)(n,"default"),m=(0,a.M)(n,"config"),f=new o.PagesAPIRouteModule({definition:{kind:s.A.PAGES_API,page:"/api/connect/verify",pathname:"/api/connect/verify",bundlePath:"",filename:""},userland:n})},69842:(e,r,t)=>{t.d(r,{A:()=>s});var n=t(39908),o=t.n(n);async function s(e,r,t){let n=o()({req:e,level:t?"deep":void 0});return console.log(n),n.payload}},64166:(e,r,t)=>{t.d(r,{A:()=>l});var n=t(55591),o=t.n(n);let s=require("http");var a=t.n(s),i=t(79551);function l({url:e,method:r,hostname:t,path:n,headers:s,body:l,port:u,scheme:c}){let d=l?JSON.stringify(l):null,p=e?new i.URL(e):null,m={method:r||"GET",hostname:p?p.hostname:t,port:c?.match(/https/i)?443:p?p.protocol?.match(/https/i)?443:p.port:u?Number(u):80,headers:{}};return n&&(m.path=n),s&&(m.headers=s),l&&(m.headers["Content-Type"]="application/json",m.headers["Content-Length"]=d?Buffer.from(d).length:void 0),new Promise((e,r)=>{let t=(c?.match(/https/i)?o():p?.protocol?.match(/https/i)?o():a()).request(m,t=>{var n="";t.on("data",function(e){n+=e}),t.on("end",function(){e(n)}),t.on("error",e=>{console.log("HTTP response error =>",e.message),r(`HTTP response error =>, ${e.message}`)}),t.on("close",()=>{console.log("HTTP(S) Response Closed Successfully")})});l&&t.write(d),t.on("error",e=>{console.log("HTTPS request ERROR =>",e.message),r(`HTTP request error =>, ${e.message}`)}),t.end()})}},67619:(e,r,t)=>{t.d(r,{A:()=>s});var n=t(29021),o=t.n(n);async function s({user:e,message:r,component:t,noMail:n,req:s}){let a=new Date,i=(()=>{if(!s)return null;try{let e=s.headers["x-forwarded-for"],r=s.headers["x-real-ip"],t=s.headers["cf-connecting-ip"],n=Array.isArray(e)?e[0]:e?.split(",")[0],o=t||n||r||s.socket.remoteAddress;if(!o)return null;return String(o)}catch(e){return null}})();try{let n=`🚀 SERVER ERROR ===========================
2024-12-08 19:56:57 +00:00
Error Message: ${r}
2025-01-14 15:27:08 +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-14 15:27:08 +00:00
User Email: ${e?.email}`),s?.url&&(n+=`
URL: ${s.url}`),s?.body&&(n+=`
Request Body: ${JSON.stringify(s.body,null,4)}`),i&&(n+=`
IP: ${i}`),n+=`
Date: ${a.toDateString()}
========================================`,o().existsSync("./.tmp/error.log")||o().writeFileSync("./.tmp/error.log","","utf-8");let l=o().readFileSync("./.tmp/error.log","utf-8");o().writeFileSync("./.tmp/error.log",n),o().appendFileSync("./.tmp/error.log",`
2024-12-08 19:56:57 +00:00
2025-01-14 15:27:08 +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=77666);module.exports=t})();