Added tests to adapter loader, cleaned up README, renamed to GCS_BUCKET from GCS_BUCKET_NAME
This commit is contained in:
22
README.md
22
README.md
@@ -135,9 +135,14 @@ PARSE_SERVER_MAX_UPLOAD_SIZE
|
||||
|
||||
```
|
||||
|
||||
##### Configuring S3 Adapter
|
||||
##### Configuring File Adapters
|
||||
Parse Server allows developers to choose from several options when hosting files: the `GridStoreAdapter`, which backed by MongoDB; the `S3Adapter`, which is backed by [Amazon S3](https://aws.amazon.com/s3/); or the `GCSAdapter`, which is backed by [Google Cloud Storage](https://cloud.google.com/storage/).
|
||||
|
||||
You can use the following environment variable setup the S3 adapter
|
||||
`GridStoreAdapter` is used by default and requires no setup, but if you're interested in using S3 or GCS, additional configuration information is available below.
|
||||
|
||||
###### Configuring `S3Adapter`
|
||||
|
||||
You can use the following environment variable setup to enable the S3 adapter:
|
||||
|
||||
```js
|
||||
S3_ACCESS_KEY
|
||||
@@ -149,6 +154,19 @@ S3_DIRECT_ACCESS
|
||||
|
||||
```
|
||||
|
||||
###### Configuring `GCSAdapter`
|
||||
|
||||
You can use the following environment variable setup to enable the GCS adapter:
|
||||
|
||||
```js
|
||||
GCP_PROJECT_ID
|
||||
GCP_KEYFILE_PATH
|
||||
GCS_BUCKET
|
||||
GCS_BUCKET_PREFIX
|
||||
GCS_DIRECT_ACCESS
|
||||
|
||||
```
|
||||
|
||||
## Contributing
|
||||
|
||||
We really want Parse to be yours, to see it grow and thrive in the open source community. Please see the [Contributing to Parse Server guide](CONTRIBUTING.md).
|
||||
|
||||
@@ -3,6 +3,7 @@ var loadAdapter = require("../src/Adapters/AdapterLoader").loadAdapter;
|
||||
var FilesAdapter = require("../src/Adapters/Files/FilesAdapter").default;
|
||||
var ParsePushAdapter = require("../src/Adapters/Push/ParsePushAdapter");
|
||||
var S3Adapter = require("../src/Adapters/Files/S3Adapter").default;
|
||||
var GCSAdapter = require("../src/Adapters/Files/GCSAdapter").default;
|
||||
|
||||
describe("AdapterLoader", ()=>{
|
||||
|
||||
@@ -109,4 +110,13 @@ describe("AdapterLoader", ()=>{
|
||||
}).not.toThrow();
|
||||
done();
|
||||
})
|
||||
|
||||
it("should load GCSAdapter from direct passing", (done) => {
|
||||
var gcsAdapter = new GCSAdapter("projectId", "path/to/keyfile", "bucket")
|
||||
expect(() => {
|
||||
var adapter = loadAdapter(gcsAdapter, FilesAdapter);
|
||||
expect(adapter).toBe(gcsAdapter);
|
||||
}).not.toThrow();
|
||||
done();
|
||||
})
|
||||
});
|
||||
|
||||
@@ -32,21 +32,21 @@ describe("FilesController",()=>{
|
||||
console.log("set S3_ACCESS_KEY and S3_SECRET_KEY to test S3Adapter")
|
||||
}
|
||||
|
||||
if (process.env.GCP_PROJECT_ID && process.env.GCP_KEYFILE_PATH && process.env.GCS_BUCKET_NAME) {
|
||||
if (process.env.GCP_PROJECT_ID && process.env.GCP_KEYFILE_PATH && process.env.GCS_BUCKET) {
|
||||
|
||||
// Test the GCS Adapter
|
||||
var gcsAdapter = new GCSAdapter(process.env.GCP_PROJECT_ID, process.env.GCP_KEYFILE_PATH, process.env.GCS_BUCKET_NAME);
|
||||
var gcsAdapter = new GCSAdapter(process.env.GCP_PROJECT_ID, process.env.GCP_KEYFILE_PATH, process.env.GCS_BUCKET);
|
||||
|
||||
FCTestFactory.testAdapter("GCSAdapter", gcsAdapter);
|
||||
|
||||
// Test GCS with direct access
|
||||
var gcsDirectAccessAdapter = new GCSAdapter(process.env.GCP_PROJECT_ID, process.env.GCP_KEYFILE_PATH, process.env.GCS_BUCKET_NAME, {
|
||||
var gcsDirectAccessAdapter = new GCSAdapter(process.env.GCP_PROJECT_ID, process.env.GCP_KEYFILE_PATH, process.env.GCS_BUCKET, {
|
||||
directAccess: true
|
||||
});
|
||||
|
||||
FCTestFactory.testAdapter("GCSAdapterDirect", gcsDirectAccessAdapter);
|
||||
|
||||
} else if (!process.env.TRAVIS) {
|
||||
console.log("set GCP_PROJECT_ID, GCP_KEYFILE_PATH, and GCS_BUCKET_NAME to test GCSAdapter")
|
||||
console.log("set GCP_PROJECT_ID, GCP_KEYFILE_PATH, and GCS_BUCKET to test GCSAdapter")
|
||||
}
|
||||
});
|
||||
|
||||
@@ -28,7 +28,7 @@ export class GCSAdapter extends FilesAdapter {
|
||||
constructor(
|
||||
projectId = requiredOrFromEnvironment('GCP_PROJECT_ID', 'projectId'),
|
||||
keyFilename = requiredOrFromEnvironment('GCP_KEYFILE_PATH', 'keyfile path'),
|
||||
bucket = requiredOrFromEnvironment('GCS_BUCKET_NAME', 'bucket name'),
|
||||
bucket = requiredOrFromEnvironment('GCS_BUCKET', 'bucket name'),
|
||||
{ bucketPrefix = fromEnvironmentOrDefault('GCS_BUCKET_PREFIX', ''),
|
||||
directAccess = fromEnvironmentOrDefault('GCS_DIRECT_ACCESS', false) } = {}) {
|
||||
super();
|
||||
|
||||
Reference in New Issue
Block a user