diff --git a/CHANGELOG.md b/CHANGELOG.md index fd2b76864c..da0b9556af 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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) diff --git a/package.json b/package.json index a4df201cbc..e5e5379e4e 100644 --- a/package.json +++ b/package.json @@ -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", @@ -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", diff --git a/spec/AdapterLoader.spec.js b/spec/AdapterLoader.spec.js index b02e07e708..72c6ef333c 100644 --- a/spec/AdapterLoader.spec.js +++ b/spec/AdapterLoader.spec.js @@ -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', () => { @@ -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(); }); diff --git a/spec/dependencies/mock-files-adapter/index.js b/spec/dependencies/mock-files-adapter/index.js new file mode 100644 index 0000000000..ad5e301da7 --- /dev/null +++ b/spec/dependencies/mock-files-adapter/index.js @@ -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; diff --git a/spec/dependencies/mock-files-adapter/package.json b/spec/dependencies/mock-files-adapter/package.json new file mode 100644 index 0000000000..8deb89f5a0 --- /dev/null +++ b/spec/dependencies/mock-files-adapter/package.json @@ -0,0 +1,6 @@ +{ + "name": "mock-files-adapter", + "version": "1.0.0", + "description": "Mock files adapter for tests.", + "main": "index.js" +} diff --git a/spec/index.spec.js b/spec/index.spec.js index e2e50f1d9c..cadc03ef55 100644 --- a/spec/index.spec.js +++ b/spec/index.spec.js @@ -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' ); diff --git a/src/index.js b/src/index.js index 2806fb8b42..03cd15176f 100644 --- a/src/index.js +++ b/src/index.js @@ -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'; @@ -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', {