Merge branch 'master' of https://github.com/ParsePlatform/parse-server into mcdonald-gcs-adapter

* 'master' of https://github.com/ParsePlatform/parse-server:
  Remove limit when counting results.
  beforeSave changes should propagate to the response
  Fix delete relation field when _Join collection not exist
  Test empty authData block on login for #413
  Fix for related query on non-existing column
  Fix Markdown format: make checkboxes visible
  Fix create wrong _Session for Facebook login
  Modified the npm dev script to support Windows
  Improves tests, ensure unicity of roleIds
  Fix reversed roles lookup
  Fix leak warnings in tests, use mongodb-runner from node_modules
  Improves documentation, add loading tests
  Improves loading of Push Adapter, fix loading of S3Adapter
  Adds public_html and views for packaging
  Removes shebang for windows
  Better support for windows builds
  Fix add field to system schema
  Convert Schema.js to ES6 class.
This commit is contained in:
Mike McDonald
2016-03-06 15:34:40 -08:00
20 changed files with 740 additions and 469 deletions

View File

@@ -28,15 +28,8 @@ export function loadAdapter(adapter, defaultAdapter, options) {
return loadAdapter(adapter.class, undefined, adapter.options);
} else if (adapter.adapter) {
return loadAdapter(adapter.adapter, undefined, adapter.options);
} else {
// Try to load the defaultAdapter with the options
// The default adapter should throw if the options are
// incompatible
try {
return loadAdapter(defaultAdapter, undefined, adapter);
} catch (e) {};
}
// return the adapter as is as it's unusable otherwise
// return the adapter as provided
return adapter;
}

View File

@@ -8,19 +8,20 @@ import requiredParameter from '../../requiredParameter';
const DEFAULT_S3_REGION = "us-east-1";
function parseS3AdapterOptions(...options) {
if (options.length === 1 && typeof options[0] == "object") {
return options;
function requiredOrFromEnvironment(env, name) {
let environmentVariable = process.env[env];
if (!environmentVariable) {
requiredParameter(`S3Adapter requires an ${name}`);
}
const additionalOptions = options[3] || {};
return {
accessKey: options[0],
secretKey: options[1],
bucket: options[2],
region: additionalOptions.region
return environmentVariable;
}
function fromEnvironmentOrDefault(env, defaultValue) {
let environmentVariable = process.env[env];
if (environmentVariable) {
return environmentVariable;
}
return defaultValue;
}
export class S3Adapter extends FilesAdapter {
@@ -28,12 +29,12 @@ export class S3Adapter extends FilesAdapter {
// Providing AWS access and secret keys is mandatory
// Region and bucket will use sane defaults if omitted
constructor(
accessKey = requiredParameter('S3Adapter requires an accessKey'),
secretKey = requiredParameter('S3Adapter requires a secretKey'),
bucket,
{ region = DEFAULT_S3_REGION,
bucketPrefix = '',
directAccess = false } = {}) {
accessKey = requiredOrFromEnvironment('S3_ACCESS_KEY', 'accessKey'),
secretKey = requiredOrFromEnvironment('S3_SECRET_KEY', 'secretKey'),
bucket = fromEnvironmentOrDefault('S3_BUCKET', undefined),
{ region = fromEnvironmentOrDefault('S3_REGION', DEFAULT_S3_REGION),
bucketPrefix = fromEnvironmentOrDefault('S3_BUCKET_PREFIX', ''),
directAccess = fromEnvironmentOrDefault('S3_DIRECT_ACCESS', false) } = {}) {
super();
this._region = region;