8 lines
3.6 KiB
JavaScript
8 lines
3.6 KiB
JavaScript
"use strict";(()=>{var e={};e.id=7258,e.ids=[7258],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")},96762:(e,s)=>{Object.defineProperty(s,"M",{enumerable:!0,get:function(){return function e(s,r){return r in s?s[r]:"then"in s&&"function"==typeof s.then?s.then(s=>e(s,r)):"function"==typeof s&&"default"===r?s:void 0}}})},45310:(e,s,r)=>{r.r(s),r.d(s,{config:()=>l,default:()=>d,routeModule:()=>c});var t={};r.r(t),r.d(t,{default:()=>o});var a=r(89947),n=r(2706),i=r(96762),u=r(48786),_=r(69842);async function o(e,s){if("GET"!==e.method)return s.json({msg:"Failed!"});let r=await (0,_.A)(e,s);if(!r)return s.json({success:!1,msg:"Unauthorized"});let t=await (0,u.A)(`
|
|
SELECT
|
|
user_users.user_id,user_users.database_access,user_users.user_id,user_users.user_priviledge,users.first_name,users.last_name,users.email,users.image_thumbnail
|
|
FROM
|
|
user_users JOIN users ON user_users.user_id=users.id
|
|
WHERE
|
|
user_users.invited_user_id='${r.id}'
|
|
`),a=[];if(t&&t[0])for(let e=0;e<t.length;e++){let s=t[e],{database_access:r,user_id:n,user_priviledge:i}=s;if(!r?.match(/./))continue;let _=await (0,u.A)(`SELECT * FROM user_databases WHERE (${r.split("|").map(e=>`db_slug='${e}'`).join(" OR ")}) AND user_id=${n}`);for(let e=0;e<_.length;e++){let r=_[e];a.push({id:r.id,user_id:s.user_id,first_name:s.first_name,last_name:s.last_name,email:s.email,image_thumbnail:s.image_thumbnail,db_name:r.db_name,db_slug:r.db_slug,db_full_name:r.db_full_name,db_image:r.db_image,db_description:r.db_description,date_created:r.date_created,user_priviledge:i})}}s.json({success:!0,databases:a})}let d=(0,i.M)(t,"default"),l=(0,i.M)(t,"config"),c=new a.PagesAPIRouteModule({definition:{kind:n.A.PAGES_API,page:"/api/getDelegatedDatabases",pathname:"/api/getDelegatedDatabases",bundlePath:"",filename:""},userland:t})},69842:(e,s,r)=>{r.d(s,{A:()=>n});var t=r(39908),a=r.n(t);async function n(e,s,r){let t=a()({req:e,level:r?"deep":void 0});return console.log(t),t.payload}},48786:(e,s,r)=>{r.d(s,{A:()=>a});var t=r(7447);async function a(...e){let s=(0,t.A)();try{if(!s)throw Error("No Connection provided to DB_HANDLER function!");let r=await s.query(...e);return JSON.parse(JSON.stringify(r))}catch(e){return console.log("DB Error =>",e),{success:!1,error:e.message}}finally{await s?.end()}}},7447:(e,s,r)=>{r.d(s,{A:()=>n});var t=r(9973),a=r.n(t);function n(e){return e?.ro?DSQL_READ_ONLY_DB_CONN||a()({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||a()({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||a()({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,s)=>{Object.defineProperty(s,"A",{enumerable:!0,get:function(){return r}});var r=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,s,r)=>{e.exports=r(75600)}};var s=require("../../webpack-api-runtime.js");s.C(e);var r=s(s.s=45310);module.exports=r})(); |