Skip to content

Commit 6160fb9

Browse files
committed
revert
1 parent 583f649 commit 6160fb9

File tree

3 files changed

+12
-30
lines changed

3 files changed

+12
-30
lines changed

spec/CloudCode.spec.js

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -95,19 +95,13 @@ describe('Cloud Code', () => {
9595
it('can get and set config', () => {
9696
let currentConfig = Config.get('test');
9797
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', () => {
10498
Parse.Server.set('silent', ['abc']);
105-
const currentConfig = Config.get('test');
99+
currentConfig = Config.get('test');
106100
expect(currentConfig.silent).toEqual(['abc']);
107101
});
108102

109103
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');
111105
});
112106

113107
it('show warning on duplicate cloud functions', done => {

src/Config.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -684,6 +684,15 @@ export class Config {
684684
? this.pages.pagesEndpoint
685685
: 'apps';
686686
}
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+
}
687696
}
688697

689698
export default Config;

src/ParseServer.js

Lines changed: 1 addition & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,6 @@ import { SecurityRouter } from './Routers/SecurityRouter';
4545
import CheckRunner from './Security/CheckRunner';
4646
import Deprecator from './Deprecator/Deprecator';
4747
import { DefinedSchemas } from './SchemaMigrations/DefinedSchemas';
48-
import { ParseServerOptions as ParseServerDefintions } from './Options/Definitions.js';
4948

5049
// Mutate the Parse object to add the Cloud Code handlers
5150
addParseCloud();
@@ -442,27 +441,7 @@ function addParseCloud() {
442441
if (!Parse.Server) {
443442
Object.defineProperty(Parse, 'Server', {
444443
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);
466445
},
467446
});
468447
}

0 commit comments

Comments
 (0)