"use strict";(()=>{var e={};e.id=3338,e.ids=[3338],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")},9973:e=>{e.exports=require("serverless-mysql")},29021:e=>{e.exports=require("fs")},33873:e=>{e.exports=require("path")},96762:(e,r)=>{Object.defineProperty(r,"M",{enumerable:!0,get:function(){return function e(r,o){return o in r?r[o]:"then"in r&&"function"==typeof r.then?r.then(r=>e(r,o)):"function"==typeof r&&"default"===o?r:void 0}}})},670:(e,r,o)=>{o.r(r),o.d(r,{config:()=>p,default:()=>d,routeModule:()=>A});var s={};o.r(s),o.d(s,{default:()=>D});var n=o(89947),t=o(2706),i=o(96762),a=o(29021),c=o.n(a),u=o(48786),_=o(69842),l=o(33873),S=o.n(l);async function D(e,r){if("POST"!==e.method)return r.json({msg:"Failed!"});if(!await (0,_.A)(e,r,!0))return r.json({success:!1,msg:"Unauthorized"});let{paradigm:o,payload:s}=e.body;try{console.log("Deleting media =>",s.id);let e=s.media_url,o=process.env.DSQL_STATIC_SERVER_DIR,n=process.env.DSQL_STATIC_HOST;if(!o){console.log("No Static Root Path"),r.json({success:!1,msg:"No Static Root Path"});return}let t=e.replace(n,""),i=S().join(o,t),a=c().existsSync(i);if(console.log("relativePath",t),console.log("STATIC_ROOT",o),console.log("STATIC_HOST",n),console.log("filePath",i),console.log("fileExist",a),a){r.json({success:!1});return}}catch(e){console.log("File verification Error =>",e.message),console.log("File Truly doesn't exist, cotinuing ...")}"user_media"===o&&await (0,u.A)(`DELETE FROM user_media WHERE id='${s.id}'`),r.json({success:!0})}let d=(0,i.M)(s,"default"),p=(0,i.M)(s,"config"),A=new n.PagesAPIRouteModule({definition:{kind:t.A.PAGES_API,page:"/api/purgeDb",pathname:"/api/purgeDb",bundlePath:"",filename:""},userland:s})},69842:(e,r,o)=>{o.d(r,{A:()=>t});var s=o(39908),n=o.n(s);async function t(e,r,o){let s=n()({req:e,level:o?"deep":void 0});return console.log(s),s.payload}},48786:(e,r,o)=>{o.d(r,{A:()=>n});var s=o(7447);async function n(...e){let r=(0,s.A)();try{if(!r)throw Error("No Connection provided to DB_HANDLER function!");let o=await r.query(...e);return JSON.parse(JSON.stringify(o))}catch(e){return console.log("DB Error =>",e),{success:!1,error:e.message}}finally{await r?.end()}}},7447:(e,r,o)=>{o.d(r,{A:()=>t});var s=o(9973),n=o.n(s);function t(e){return e?.ro?DSQL_READ_ONLY_DB_CONN||n()({config:{host:process.env.DSQL_DB_HOST,user:process.env.DSQL_DB_READ_ONLY_USERNAME,password:process.env.DSQL_DB_READ_ONLY_PASSWORD,port:process.env.DSQL_DB_PORT?Number(process.env.DSQL_DB_PORT):void 0,charset:"utf8mb4"}}):e?.fa?global.DSQL_FULL_ACCESS_DB_CONN||n()({config:{host:process.env.DSQL_DB_HOST,user:process.env.DSQL_DB_FULL_ACCESS_USERNAME,password:process.env.DSQL_DB_FULL_ACCESS_PASSWORD,port:process.env.DSQL_DB_PORT?Number(process.env.DSQL_DB_PORT):void 0,charset:"utf8mb4"}}):global.DSQL_DB_CONN||n()({config:{host:process.env.DSQL_DB_HOST,user:process.env.DSQL_DB_USERNAME,password:process.env.DSQL_DB_PASSWORD,database:e?.noDb?void 0:process.env.DSQL_DB_NAME,port:process.env.DSQL_DB_PORT?Number(process.env.DSQL_DB_PORT):void 0,charset:"utf8mb4"}})}},2706:(e,r)=>{Object.defineProperty(r,"A",{enumerable:!0,get:function(){return o}});var o=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,o)=>{e.exports=o(75600)}};var r=require("../../webpack-api-runtime.js");r.C(e);var o=r(r.s=670);module.exports=o})();