File tree Expand file tree Collapse file tree 3 files changed +12
-30
lines changed Expand file tree Collapse file tree 3 files changed +12
-30
lines changed Original file line number Diff line number Diff line change @@ -95,19 +95,13 @@ describe('Cloud Code', () => {
95
95
it ( 'can get and set config' , ( ) => {
96
96
let currentConfig = Config . get ( 'test' ) ;
97
97
expect ( Object . keys ( Parse . Server ) ) . toEqual ( Object . keys ( currentConfig ) ) ;
98
- Parse . Server . setSilent ( [ 'abc' ] ) ;
99
- currentConfig = Config . get ( 'test' ) ;
100
- expect ( currentConfig . silent ) . toEqual ( [ 'abc' ] ) ;
101
- } ) ;
102
-
103
- it ( 'can set config with two args' , ( ) => {
104
98
Parse . Server . set ( 'silent' , [ 'abc' ] ) ;
105
- const currentConfig = Config . get ( 'test' ) ;
99
+ currentConfig = Config . get ( 'test' ) ;
106
100
expect ( currentConfig . silent ) . toEqual ( [ 'abc' ] ) ;
107
101
} ) ;
108
102
109
103
it ( 'can throw on invalid config' , ( ) => {
110
- expect ( ( ) => Parse . Server . setFoo ( ) ) . toThrow ( 'foo is not a valid Parse Server option' ) ;
104
+ expect ( ( ) => Parse . Server . set ( 'foo' , true ) ) . toThrow ( 'foo is not a valid Parse Server option' ) ;
111
105
} ) ;
112
106
113
107
it ( 'show warning on duplicate cloud functions' , done => {
Original file line number Diff line number Diff line change @@ -684,6 +684,15 @@ export class Config {
684
684
? this . pages . pagesEndpoint
685
685
: 'apps' ;
686
686
}
687
+
688
+ set ( key , value ) {
689
+ if ( ! ParseServerOptions [ key ] ) {
690
+ throw `${ key } is not a valid Parse Server option` ;
691
+ }
692
+ this [ key ] = value ;
693
+ Config . put ( this ) ;
694
+ return this ;
695
+ }
687
696
}
688
697
689
698
export default Config ;
Original file line number Diff line number Diff line change @@ -45,7 +45,6 @@ import { SecurityRouter } from './Routers/SecurityRouter';
45
45
import CheckRunner from './Security/CheckRunner' ;
46
46
import Deprecator from './Deprecator/Deprecator' ;
47
47
import { DefinedSchemas } from './SchemaMigrations/DefinedSchemas' ;
48
- import { ParseServerOptions as ParseServerDefintions } from './Options/Definitions.js' ;
49
48
50
49
// Mutate the Parse object to add the Cloud Code handlers
51
50
addParseCloud ( ) ;
@@ -442,27 +441,7 @@ function addParseCloud() {
442
441
if ( ! Parse . Server ) {
443
442
Object . defineProperty ( Parse , 'Server' , {
444
443
get ( ) {
445
- const target = Config . get ( Parse . applicationId ) ;
446
- const handler2 = {
447
- get ( obj , prop ) {
448
- if ( prop . substring ( 0 , 3 ) === 'set' ) {
449
- const assignValue = ( key , value ) => {
450
- if ( ! ParseServerDefintions [ key ] ) {
451
- throw `${ key } is not a valid Parse Server option` ;
452
- }
453
- obj [ key ] = value ;
454
- Config . put ( obj ) ;
455
- } ;
456
- if ( prop . length === 3 ) {
457
- return assignValue ;
458
- }
459
- const method = `${ prop . charAt ( 3 ) . toLowerCase ( ) } ${ prop . substring ( 4 , prop . length ) } ` ;
460
- return value => assignValue ( method , value ) ;
461
- }
462
- return obj [ prop ] ;
463
- } ,
464
- } ;
465
- return new Proxy ( target , handler2 ) ;
444
+ return Config . get ( Parse . applicationId ) ;
466
445
} ,
467
446
} ) ;
468
447
}
You can’t perform that action at this time.
0 commit comments