Require a server URL

This commit is contained in:
Drew Gross
2016-02-23 12:54:20 -08:00
parent 531e2ffea8
commit 2dc080fd00
3 changed files with 16 additions and 16 deletions

View File

@@ -2,8 +2,9 @@ var request = require('request');
describe('server', () => {
it('requires a master key and app id', done => {
expect(setServerConfiguration.bind(undefined, { masterKey: 'mykey' })).toThrow('You must provide an appId and masterKey!');
expect(setServerConfiguration.bind(undefined, { appId: 'myId' })).toThrow('You must provide an appId and masterKey!');
expect(setServerConfiguration.bind(undefined, { })).toThrow('You must provide an appId!');
expect(setServerConfiguration.bind(undefined, { appId: 'myId' })).toThrow('You must provide a masterKey!');
expect(setServerConfiguration.bind(undefined, { appId: 'myId', masterKey: 'mk' })).toThrow('You must provide a serverURL!');
done();
});

View File

@@ -31,12 +31,13 @@ import { SchemasRouter } from './Routers/SchemasRouter';
import { IAPValidationRouter } from './Routers/IAPValidationRouter';
import { PushRouter } from './Routers/PushRouter';
import { FilesRouter } from './Routers/FilesRouter';
import { LogsRouter } from './Routers/LogsRouter';
import { LogsRouter } from './Routers/LogsRouter';
import { loadAdapter } from './Adapters/AdapterLoader';
import { loadAdapter } from './Adapters/AdapterLoader';
import { FileLoggerAdapter } from './Adapters/Logger/FileLoggerAdapter';
import { LoggerController } from './Controllers/LoggerController';
import requiredParameter from './requiredParameter';
// Mutate the Parse object to add the Cloud Code handlers
addParseCloud();
@@ -65,8 +66,8 @@ addParseCloud();
// "push": optional key from configure push
function ParseServer({
appId,
masterKey,
appId = requiredParameter('You must provide an appId!'),
masterKey = requiredParameter('You must provide a masterKey!'),
databaseAdapter,
filesAdapter,
push,
@@ -82,13 +83,9 @@ function ParseServer({
facebookAppIds = [],
enableAnonymousUsers = true,
oauth = {},
serverURL = '',
serverURL = requiredParameter('You must provide a serverURL!'),
maxUploadSize = '20mb'
}) {
if (!appId || !masterKey) {
throw 'You must provide an appId and masterKey!';
}
if (databaseAdapter) {
DatabaseAdapter.setAdapter(databaseAdapter);
}

2
src/requiredParameter.js Normal file
View File

@@ -0,0 +1,2 @@
/* @flow */
export default (errorMessage: string) => {throw errorMessage}