fix: custom database options are not passed to MongoDB GridFS (#7911)
This commit is contained in:
@@ -43,6 +43,20 @@ describe('FilesController', () => {
|
|||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it_only_db('mongo')('should pass databaseOptions to GridFSBucketAdapter', async () => {
|
||||||
|
await reconfigureServer({
|
||||||
|
databaseURI: 'mongodb://localhost:27017/parse',
|
||||||
|
filesAdapter: null,
|
||||||
|
databaseAdapter: null,
|
||||||
|
databaseOptions: {
|
||||||
|
retryWrites: true,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
const config = Config.get(Parse.applicationId);
|
||||||
|
expect(config.database.adapter._mongoOptions.retryWrites).toBeTrue();
|
||||||
|
expect(config.filesController.adapter._mongoOptions.retryWrites).toBeTrue();
|
||||||
|
});
|
||||||
|
|
||||||
it('should create a server log on failure', done => {
|
it('should create a server log on failure', done => {
|
||||||
const logController = new LoggerController(new WinstonLoggerAdapter());
|
const logController = new LoggerController(new WinstonLoggerAdapter());
|
||||||
|
|
||||||
|
|||||||
@@ -91,12 +91,20 @@ export function getLoggerController(options: ParseServerOptions): LoggerControll
|
|||||||
}
|
}
|
||||||
|
|
||||||
export function getFilesController(options: ParseServerOptions): FilesController {
|
export function getFilesController(options: ParseServerOptions): FilesController {
|
||||||
const { appId, databaseURI, filesAdapter, databaseAdapter, preserveFileName, fileKey } = options;
|
const {
|
||||||
|
appId,
|
||||||
|
databaseURI,
|
||||||
|
databaseOptions = {},
|
||||||
|
filesAdapter,
|
||||||
|
databaseAdapter,
|
||||||
|
preserveFileName,
|
||||||
|
fileKey,
|
||||||
|
} = options;
|
||||||
if (!filesAdapter && databaseAdapter) {
|
if (!filesAdapter && databaseAdapter) {
|
||||||
throw 'When using an explicit database adapter, you must also use an explicit filesAdapter.';
|
throw 'When using an explicit database adapter, you must also use an explicit filesAdapter.';
|
||||||
}
|
}
|
||||||
const filesControllerAdapter = loadAdapter(filesAdapter, () => {
|
const filesControllerAdapter = loadAdapter(filesAdapter, () => {
|
||||||
return new GridFSBucketAdapter(databaseURI, {}, fileKey);
|
return new GridFSBucketAdapter(databaseURI, databaseOptions, fileKey);
|
||||||
});
|
});
|
||||||
return new FilesController(filesControllerAdapter, appId, {
|
return new FilesController(filesControllerAdapter, appId, {
|
||||||
preserveFileName,
|
preserveFileName,
|
||||||
|
|||||||
Reference in New Issue
Block a user