Skip to content

Commit

Permalink
Merge branch 'alpha' into ci-speedup
Browse files Browse the repository at this point in the history
  • Loading branch information
mtrezza authored Jul 8, 2024
2 parents f90e4b9 + c764203 commit 05cc7aa
Show file tree
Hide file tree
Showing 7 changed files with 213 additions and 237 deletions.
7 changes: 7 additions & 0 deletions changelogs/CHANGELOG_alpha.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
# [7.1.0-alpha.15](https://github.com/parse-community/parse-server/compare/7.1.0-alpha.14...7.1.0-alpha.15) (2024-07-08)


### Features

* Upgrade to @parse/push-adapter 6.4.0 ([#9182](https://github.com/parse-community/parse-server/issues/9182)) ([ef1634b](https://github.com/parse-community/parse-server/commit/ef1634bf1f360429108d29b08032fc7961ff96a1))

# [7.1.0-alpha.14](https://github.com/parse-community/parse-server/compare/7.1.0-alpha.13...7.1.0-alpha.14) (2024-07-07)


Expand Down
395 changes: 179 additions & 216 deletions package-lock.json

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "parse-server",
"version": "7.1.0-alpha.14",
"version": "7.1.0-alpha.15",
"description": "An express module providing a Parse-compatible API server",
"main": "lib/index.js",
"repository": {
Expand All @@ -25,7 +25,7 @@
"@graphql-tools/schema": "10.0.3",
"@graphql-tools/utils": "8.12.0",
"@parse/fs-files-adapter": "3.0.0",
"@parse/push-adapter": "6.2.0",
"@parse/push-adapter": "6.4.0",
"bcryptjs": "2.4.3",
"body-parser": "1.20.2",
"commander": "12.0.0",
Expand Down
7 changes: 3 additions & 4 deletions spec/AdapterLoader.spec.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
const loadAdapter = require('../lib/Adapters/AdapterLoader').loadAdapter;
const { loadAdapter, loadModule } = require('../lib/Adapters/AdapterLoader');
const FilesAdapter = require('@parse/fs-files-adapter').default;
const ParsePushAdapter = require('@parse/push-adapter').default;
const MockFilesAdapter = require('mock-files-adapter');
const Config = require('../lib/Config');

Expand Down Expand Up @@ -103,19 +102,19 @@ describe('AdapterLoader', () => {
done();
});

it('should load push adapter from options', done => {
it('should load push adapter from options', async () => {
const options = {
android: {
senderId: 'yolo',
apiKey: 'yolo',
},
};
const ParsePushAdapter = await loadModule('@parse/push-adapter');
expect(() => {
const adapter = loadAdapter(undefined, ParsePushAdapter, options);
expect(adapter.constructor).toBe(ParsePushAdapter);
expect(adapter).not.toBe(undefined);
}).not.toThrow();
done();
});

it('should load custom push adapter from string (#3544)', done => {
Expand Down
17 changes: 17 additions & 0 deletions src/Adapters/AdapterLoader.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,4 +46,21 @@ export function loadAdapter<T>(adapter, defaultAdapter, options): T {
return adapter;
}

export async function loadModule(modulePath) {
let module;
try {
module = require(modulePath);
} catch (err) {
if (err.code === 'ERR_REQUIRE_ESM') {
module = await import(modulePath);
if (module.default) {
module = module.default;
}
} else {
throw err;
}
}
return module;
}

export default loadAdapter;
18 changes: 3 additions & 15 deletions src/Controllers/index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import authDataManager from '../Adapters/Auth';
import { ParseServerOptions } from '../Options';
import { loadAdapter } from '../Adapters/AdapterLoader';
import { loadAdapter, loadModule } from '../Adapters/AdapterLoader';
import defaults from '../defaults';
// Controllers
import { LoggerController } from './LoggerController';
Expand All @@ -22,21 +22,13 @@ import { InMemoryCacheAdapter } from '../Adapters/Cache/InMemoryCacheAdapter';
import { AnalyticsAdapter } from '../Adapters/Analytics/AnalyticsAdapter';
import MongoStorageAdapter from '../Adapters/Storage/Mongo/MongoStorageAdapter';
import PostgresStorageAdapter from '../Adapters/Storage/Postgres/PostgresStorageAdapter';
import ParsePushAdapter from '@parse/push-adapter';
import ParseGraphQLController from './ParseGraphQLController';
import SchemaCache from '../Adapters/Cache/SchemaCache';

export function getControllers(options: ParseServerOptions) {
const loggerController = getLoggerController(options);
const filesController = getFilesController(options);
const userController = getUserController(options);
const {
pushController,
hasPushScheduledSupport,
hasPushSupport,
pushControllerQueue,
pushWorker,
} = getPushController(options);
const cacheController = getCacheController(options);
const analyticsController = getAnalyticsController(options);
const liveQueryController = getLiveQueryController(options);
Expand All @@ -51,11 +43,6 @@ export function getControllers(options: ParseServerOptions) {
loggerController,
filesController,
userController,
pushController,
hasPushScheduledSupport,
hasPushSupport,
pushWorker,
pushControllerQueue,
analyticsController,
cacheController,
parseGraphQLController,
Expand Down Expand Up @@ -182,7 +169,7 @@ interface PushControlling {
pushWorker: PushWorker;
}

export function getPushController(options: ParseServerOptions): PushControlling {
export async function getPushController(options: ParseServerOptions): PushControlling {
const { scheduledPush, push } = options;

const pushOptions = Object.assign({}, push);
Expand All @@ -192,6 +179,7 @@ export function getPushController(options: ParseServerOptions): PushControlling
}

// Pass the push options too as it works with the default
const ParsePushAdapter = await loadModule('@parse/push-adapter');
const pushAdapter = loadAdapter(
pushOptions && pushOptions.adapter,
ParsePushAdapter,
Expand Down
2 changes: 2 additions & 0 deletions src/ParseServer.js
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,7 @@ class ParseServer {
throw e;
}
}
const pushController = await controllers.getPushController(this.config);
await hooksController.load();
const startupPromises = [];
if (schema) {
Expand Down Expand Up @@ -196,6 +197,7 @@ class ParseServer {
new CheckRunner(security).run();
}
this.config.state = 'ok';
this.config = { ...this.config, ...pushController };
Config.put(this.config);
return this;
} catch (error) {
Expand Down

0 comments on commit 05cc7aa

Please sign in to comment.