Skip to content

Commit

Permalink
feat: add convenience access to Parse Server configuration in Cloud C…
Browse files Browse the repository at this point in the history
…ode via `Parse.Server` (parse-community#8244)
  • Loading branch information
dblythy authored Oct 29, 2022
1 parent eab9cdd commit 9f11115
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
10 changes: 10 additions & 0 deletions spec/CloudCode.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,16 @@ describe('Cloud Code', () => {
});
});

it('can get config', () => {
const config = Parse.Server;
let currentConfig = Config.get('test');
expect(Object.keys(config)).toEqual(Object.keys(currentConfig));
config.silent = false;
Parse.Server = config;
currentConfig = Config.get('test');
expect(currentConfig.silent).toBeFalse();
});

it('show warning on duplicate cloud functions', done => {
const logger = require('../lib/logger').logger;
spyOn(logger, 'warn').and.callFake(() => {});
Expand Down
10 changes: 10 additions & 0 deletions src/ParseServer.js
Original file line number Diff line number Diff line change
Expand Up @@ -374,6 +374,16 @@ class ParseServer {

function addParseCloud() {
const ParseCloud = require('./cloud-code/Parse.Cloud');
Object.defineProperty(Parse, 'Server', {
get() {
return Config.get(Parse.applicationId);
},
set(newVal) {
newVal.appId = Parse.applicationId;
Config.put(newVal);
},
configurable: true,
});
Object.assign(Parse.Cloud, ParseCloud);
global.Parse = Parse;
}
Expand Down

0 comments on commit 9f11115

Please sign in to comment.