Skip to content

Commit 9f11115

Browse files
authored
feat: add convenience access to Parse Server configuration in Cloud Code via Parse.Server (parse-community#8244)
1 parent eab9cdd commit 9f11115

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-0
lines changed

spec/CloudCode.spec.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,16 @@ describe('Cloud Code', () => {
5050
});
5151
});
5252

53+
it('can get config', () => {
54+
const config = Parse.Server;
55+
let currentConfig = Config.get('test');
56+
expect(Object.keys(config)).toEqual(Object.keys(currentConfig));
57+
config.silent = false;
58+
Parse.Server = config;
59+
currentConfig = Config.get('test');
60+
expect(currentConfig.silent).toBeFalse();
61+
});
62+
5363
it('show warning on duplicate cloud functions', done => {
5464
const logger = require('../lib/logger').logger;
5565
spyOn(logger, 'warn').and.callFake(() => {});

src/ParseServer.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -374,6 +374,16 @@ class ParseServer {
374374

375375
function addParseCloud() {
376376
const ParseCloud = require('./cloud-code/Parse.Cloud');
377+
Object.defineProperty(Parse, 'Server', {
378+
get() {
379+
return Config.get(Parse.applicationId);
380+
},
381+
set(newVal) {
382+
newVal.appId = Parse.applicationId;
383+
Config.put(newVal);
384+
},
385+
configurable: true,
386+
});
377387
Object.assign(Parse.Cloud, ParseCloud);
378388
global.Parse = Parse;
379389
}

0 commit comments

Comments
 (0)