feat: add convenience access to Parse Server configuration in Cloud Code via Parse.Server (#8244)
This commit is contained in:
@@ -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 => {
|
it('show warning on duplicate cloud functions', done => {
|
||||||
const logger = require('../lib/logger').logger;
|
const logger = require('../lib/logger').logger;
|
||||||
spyOn(logger, 'warn').and.callFake(() => {});
|
spyOn(logger, 'warn').and.callFake(() => {});
|
||||||
|
|||||||
@@ -374,6 +374,16 @@ class ParseServer {
|
|||||||
|
|
||||||
function addParseCloud() {
|
function addParseCloud() {
|
||||||
const ParseCloud = require('./cloud-code/Parse.Cloud');
|
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);
|
Object.assign(Parse.Cloud, ParseCloud);
|
||||||
global.Parse = Parse;
|
global.Parse = Parse;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user