2024-11-05 11:12:42 +00:00
"use strict" ;
( ( ) => {
var exports = { } ;
exports . id = 4265 ;
exports . ids = [ 4265 ] ;
exports . modules = {
/***/ 2261 :
/***/ ( ( module ) => {
module . exports = require ( "serverless-mysql" ) ;
/***/ } ) ,
/***/ 4300 :
/***/ ( ( module ) => {
module . exports = require ( "buffer" ) ;
/***/ } ) ,
/***/ 6113 :
/***/ ( ( module ) => {
module . exports = require ( "crypto" ) ;
/***/ } ) ,
/***/ 7147 :
/***/ ( ( module ) => {
module . exports = require ( "fs" ) ;
/***/ } ) ,
/***/ 3685 :
/***/ ( ( module ) => {
module . exports = require ( "http" ) ;
/***/ } ) ,
/***/ 3990 :
/***/ ( ( _ _unused _webpack _module , _ _webpack _exports _ _ , _ _webpack _require _ _ ) => {
_ _webpack _require _ _ . r ( _ _webpack _exports _ _ ) ;
/* harmony export */ _ _webpack _require _ _ . d ( _ _webpack _exports _ _ , {
/* harmony export */ "default" : ( ) => ( /* binding */ handler )
/* harmony export */ } ) ;
/* harmony import */ var _package _shared _utils _backend _global _db _DB _HANDLER _ _WEBPACK _IMPORTED _MODULE _0 _ _ = _ _webpack _require _ _ ( 2224 ) ;
/* harmony import */ var _package _shared _utils _backend _global _db _DB _HANDLER _ _WEBPACK _IMPORTED _MODULE _0 _ _ _default = /*#__PURE__*/ _ _webpack _require _ _ . n ( _package _shared _utils _backend _global _db _DB _HANDLER _ _WEBPACK _IMPORTED _MODULE _0 _ _ ) ;
/* harmony import */ var _functions _backend _userAuth _ _WEBPACK _IMPORTED _MODULE _1 _ _ = _ _webpack _require _ _ ( 6825 ) ;
/* harmony import */ var _functions _backend _userAuth _ _WEBPACK _IMPORTED _MODULE _1 _ _ _default = /*#__PURE__*/ _ _webpack _require _ _ . n ( _functions _backend _userAuth _ _WEBPACK _IMPORTED _MODULE _1 _ _ ) ;
// @ts-check
/ * *
* === === === === === === === === === === === === === === === === === === === === === === === === === ===
* Imports
* === === === === === === === === === === === === === === === === === === === === === === === === === ===
* /
/** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ / * *
* API handler
* === === === === === === === === === === === === === === === === === === === === === === === === === ===
* @ type { import ( "next" ) . NextApiHandler }
* / a s y n c f u n c t i o n h a n d l e r ( r e q , r e s ) {
/ * *
* Check method
*
* @ description Check request method and return if invalid
* / i f ( r e q . m e t h o d ! = = " G E T " ) r e t u r n r e s . j s o n ( {
msg : "Failed!"
} ) ;
/ * *
* User auth
*
* @ description Authenticate user
* / c o n s t u s e r = a w a i t _ f u n c t i o n s _ b a c k e n d _ u s e r A u t h _ _ W E B P A C K _ I M P O R T E D _ M O D U L E _ 1 _ _ _ d e f a u l t ( ) ( r e q , r e s ) ;
if ( ! user ) {
return res . json ( {
success : false ,
msg : "Unauthorized"
} ) ;
}
/ * *
* User auth
*
* @ description Authenticate user
* / c o n s t d e l e g e t e d D b A c c e s s = a w a i t _ p a c k a g e _ s h a r e d _ u t i l s _ b a c k e n d _ g l o b a l _ d b _ D B _ H A N D L E R _ _ W E B P A C K _ I M P O R T E D _ M O D U L E _ 0 _ _ _ d e f a u l t ( ) ( `
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 = '${user.id}'
` );
let databasesArray = [ ] ;
if ( delegetedDbAccess && delegetedDbAccess [ 0 ] ) {
for ( let i = 0 ; i < delegetedDbAccess . length ; i ++ ) {
const deleDbAccessObject = delegetedDbAccess [ i ] ;
const { database _access , user _id , user _priviledge } = deleDbAccessObject ;
if ( ! database _access ? . match ( /./ ) ) continue ;
const delegetedDbs = await _package _shared _utils _backend _global _db _DB _HANDLER _ _WEBPACK _IMPORTED _MODULE _0 _ _ _default ( ) ( ` SELECT * FROM user_databases WHERE ( ${ database _access . split ( "|" ) . map ( ( /** @type {string} */ db ) => ` db_slug=' ${ db } ' ` ) . join ( " OR " ) } ) AND user_id= ${ user _id } ` ) ;
for ( let j = 0 ; j < delegetedDbs . length ; j ++ ) {
const delegetedDb = delegetedDbs [ j ] ;
databasesArray . push ( {
id : delegetedDb . id ,
user _id : deleDbAccessObject . user _id ,
first _name : deleDbAccessObject . first _name ,
last _name : deleDbAccessObject . last _name ,
email : deleDbAccessObject . email ,
image _thumbnail : deleDbAccessObject . image _thumbnail ,
db _name : delegetedDb . db _name ,
db _slug : delegetedDb . db _slug ,
db _full _name : delegetedDb . db _full _name ,
db _image : delegetedDb . db _image ,
db _description : delegetedDb . db _description ,
date _created : delegetedDb . date _created ,
user _priviledge : user _priviledge
} ) ;
}
}
}
////////////////////////////////////////
res . json ( {
success : true ,
databases : databasesArray
} ) ;
////////////////////////////////////////
}
/***/ } )
} ;
;
// load runtime
var _ _webpack _require _ _ = require ( "../../webpack-api-runtime.js" ) ;
_ _webpack _require _ _ . C ( exports ) ;
var _ _webpack _exec _ _ = ( moduleId ) => ( _ _webpack _require _ _ ( _ _webpack _require _ _ . s = moduleId ) )
2024-11-05 14:18:40 +00:00
var _ _webpack _exports _ _ = _ _webpack _require _ _ . X ( 0 , [ 2224 , 6825 ] , ( ) => ( _ _webpack _exec _ _ ( 3990 ) ) ) ;
2024-11-05 11:12:42 +00:00
module . exports = _ _webpack _exports _ _ ;
} ) ( ) ;