feat: Upgrade to @parse/push-adapter 6.4.0 (#9182)
This commit is contained in:
@@ -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;
|
||||
|
||||
@@ -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';
|
||||
@@ -22,7 +22,6 @@ 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';
|
||||
|
||||
@@ -30,13 +29,6 @@ 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);
|
||||
@@ -51,11 +43,6 @@ export function getControllers(options: ParseServerOptions) {
|
||||
loggerController,
|
||||
filesController,
|
||||
userController,
|
||||
pushController,
|
||||
hasPushScheduledSupport,
|
||||
hasPushSupport,
|
||||
pushWorker,
|
||||
pushControllerQueue,
|
||||
analyticsController,
|
||||
cacheController,
|
||||
parseGraphQLController,
|
||||
@@ -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);
|
||||
@@ -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,
|
||||
|
||||
@@ -160,6 +160,7 @@ class ParseServer {
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
const pushController = await controllers.getPushController(this.config);
|
||||
await hooksController.load();
|
||||
const startupPromises = [];
|
||||
if (schema) {
|
||||
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user