Skip to content

Commit

Permalink
Remove S3 File Adapter (parse-community#7324)
Browse files Browse the repository at this point in the history
* remove s3 adapter

* moved mock files adapter

* Update package-lock.json
  • Loading branch information
mtrezza authored and Arul- committed Apr 12, 2021
1 parent 3919b71 commit b391d0f
Show file tree
Hide file tree
Showing 7 changed files with 48 additions and 8 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ ___
- Removed [parse-server-simple-mailgun-adapter](https://github.com/parse-community/parse-server-simple-mailgun-adapter) dependency; to continue using the adapter it has to be explicitly installed (Manuel Trezza) [#7321](https://github.com/parse-community/parse-server/pull/7321)
- Remove support for MongoDB 3.6 which has reached its End-of-Life date and PostgreSQL 10 (Manuel Trezza) [#7315](https://github.com/parse-community/parse-server/pull/7315)
- Remove support for Node 10 which has reached its End-of-Life date (Manuel Trezza) [#7314](https://github.com/parse-community/parse-server/pull/7314)
- Remove S3 Files Adapter from Parse Server, instead install separately as `@parse/s3-files-adapter` (Manuel Trezza) [#?](https://github.com/parse-community/parse-server/pull/?)
### Notable Changes
- Added Parse Server Security Check to report weak security settings (Manuel Trezza, dblythy) [#7247](https://github.com/parse-community/parse-server/issues/7247)
- EXPERIMENTAL: Added new page router with placeholder rendering and localization of custom and feature pages such as password reset and email verification (Manuel Trezza) [#6891](https://github.com/parse-community/parse-server/issues/6891)
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
"@graphql-tools/utils": "6.2.4",
"@parse/fs-files-adapter": "1.2.0",
"@parse/push-adapter": "3.4.0",
"@parse/s3-files-adapter": "1.6.0",
"apollo-server-express": "2.21.0",
"bcryptjs": "2.4.3",
"body-parser": "1.19.0",
Expand Down Expand Up @@ -93,6 +92,7 @@
"lint-staged": "10.2.3",
"madge": "4.0.2",
"mock-mail-adapter": "file:spec/dependencies/mock-mail-adapter",
"mock-files-adapter": "file:spec/dependencies/mock-files-adapter",
"mongodb-runner": "4.8.1",
"mongodb-version-list": "1.0.0",
"node-fetch": "2.6.1",
Expand Down
10 changes: 5 additions & 5 deletions spec/AdapterLoader.spec.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
const loadAdapter = require('../lib/Adapters/AdapterLoader').loadAdapter;
const FilesAdapter = require('@parse/fs-files-adapter').default;
const S3Adapter = require('@parse/s3-files-adapter').default;
const ParsePushAdapter = require('@parse/push-adapter').default;
const MockFilesAdapter = require('mock-files-adapter');
const Config = require('../lib/Config');

describe('AdapterLoader', () => {
Expand Down Expand Up @@ -142,12 +142,12 @@ describe('AdapterLoader', () => {
}).not.toThrow();
});

it('should load S3Adapter from direct passing', done => {
it('should load file adapter from direct passing', done => {
spyOn(console, 'warn').and.callFake(() => {});
const s3Adapter = new S3Adapter('key', 'secret', 'bucket');
const mockFilesAdapter = new MockFilesAdapter('key', 'secret', 'bucket');
expect(() => {
const adapter = loadAdapter(s3Adapter, FilesAdapter);
expect(adapter).toBe(s3Adapter);
const adapter = loadAdapter(mockFilesAdapter, FilesAdapter);
expect(adapter).toBe(mockFilesAdapter);
}).not.toThrow();
done();
});
Expand Down
31 changes: 31 additions & 0 deletions spec/dependencies/mock-files-adapter/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
/**
* A mock files adapter for testing.
*/
class MockFilesAdapter {
constructor(options = {}) {
if (options.throw) {
throw 'MockFilesAdapterConstructor';
}
}
createFile() {
return 'MockFilesAdapterCreateFile';
}
deleteFile() {
return 'MockFilesAdapterDeleteFile';
}
getFileData() {
return 'MockFilesAdapterGetFileData';
}
getFileLocation() {
return 'MockFilesAdapterGetFileLocation';
}
validateFilename() {
return 'MockFilesAdapterValidateFilename';
}
handleFileStream() {
return 'MockFilesAdapterHandleFileStream';
}
}

module.exports = MockFilesAdapter;
module.exports.default = MockFilesAdapter;
6 changes: 6 additions & 0 deletions spec/dependencies/mock-files-adapter/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"name": "mock-files-adapter",
"version": "1.0.0",
"description": "Mock files adapter for tests.",
"main": "index.js"
}
4 changes: 3 additions & 1 deletion spec/index.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -389,7 +389,9 @@ describe('server', () => {
});

it('exposes correct adapters', done => {
expect(ParseServer.S3Adapter).toThrow();
expect(ParseServer.S3Adapter).toThrow(
'S3Adapter is not provided by parse-server anymore; please install @parse/s3-files-adapter'
);
expect(ParseServer.GCSAdapter).toThrow(
'GCSAdapter is not provided by parse-server anymore; please install @parse/gcs-files-adapter'
);
Expand Down
2 changes: 1 addition & 1 deletion src/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import ParseServer from './ParseServer';
import S3Adapter from '@parse/s3-files-adapter';
import FileSystemAdapter from '@parse/fs-files-adapter';
import InMemoryCacheAdapter from './Adapters/Cache/InMemoryCacheAdapter';
import NullCacheAdapter from './Adapters/Cache/NullCacheAdapter';
Expand All @@ -21,6 +20,7 @@ const _ParseServer = function (options: ParseServerOptions) {
_ParseServer.createLiveQueryServer = ParseServer.createLiveQueryServer;
_ParseServer.start = ParseServer.start;

const S3Adapter = useExternal('S3Adapter', '@parse/s3-files-adapter');
const GCSAdapter = useExternal('GCSAdapter', '@parse/gcs-files-adapter');

Object.defineProperty(module.exports, 'logger', {
Expand Down

0 comments on commit b391d0f

Please sign in to comment.