@@ -439,27 +439,38 @@ class ParseServer {
439
439
440
440
function addParseCloud ( ) {
441
441
const ParseCloud = require ( './cloud-code/Parse.Cloud' ) ;
442
- Object . defineProperty ( Parse , 'Server' , {
443
- get ( ) {
444
- const target = Config . get ( Parse . applicationId ) ;
445
- const handler2 = {
446
- get ( obj , prop ) {
447
- if ( prop . substring ( 0 , 3 ) === 'set' ) {
448
- const method = `${ prop . charAt ( 3 ) . toLowerCase ( ) } ${ prop . substring ( 4 , prop . length ) } ` ;
449
- if ( ! ParseServerDefintions [ method ] ) {
450
- throw `${ method } is not a valid Parse Server option` ;
442
+ if ( ! Parse . Server ) {
443
+ Object . defineProperty ( Parse , 'Server' , {
444
+ get ( ) {
445
+ const target = Config . get ( Parse . applicationId ) ;
446
+ const handler2 = {
447
+ get ( obj , prop ) {
448
+ if ( prop . substring ( 0 , 3 ) === 'set' ) {
449
+ const validMethod = method => {
450
+ if ( ! ParseServerDefintions [ method ] ) {
451
+ throw `${ method } is not a valid Parse Server option` ;
452
+ }
453
+ } ;
454
+ const assignValue = ( key , value ) => {
455
+ validMethod ( key ) ;
456
+ obj [ key ] = value ;
457
+ Config . put ( obj ) ;
458
+ } ;
459
+ if ( prop . length === 3 ) {
460
+ return assignValue ;
461
+ }
462
+ const method = `${ prop . charAt ( 3 ) . toLowerCase ( ) } ${ prop . substring ( 4 , prop . length ) } ` ;
463
+ return value => {
464
+ return assignValue ( method , value ) ;
465
+ } ;
451
466
}
452
- return value => {
453
- obj [ method ] = value ;
454
- Config . put ( obj ) ;
455
- } ;
456
- }
457
- return obj [ prop ] ;
458
- } ,
459
- } ;
460
- return new Proxy ( target , handler2 ) ;
461
- } ,
462
- } ) ;
467
+ return obj [ prop ] ;
468
+ } ,
469
+ } ;
470
+ return new Proxy ( target , handler2 ) ;
471
+ } ,
472
+ } ) ;
473
+ }
463
474
Object . assign ( Parse . Cloud , ParseCloud ) ;
464
475
global . Parse = Parse ;
465
476
}
0 commit comments