Skip to content
Draft
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Remove circular dependency
  • Loading branch information
dplewis committed Apr 18, 2025
commit ff4913c1d57779873f7e6f0912a0780e39e4693d
1 change: 0 additions & 1 deletion src/ClientSDK.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ module.exports = {
Object: Parse.Object,
Query: Parse.Query,
Schema: Parse.Schema,
User: Parse.User,
compatible,
supportsForwardDelete,
fromString,
Expand Down
2 changes: 1 addition & 1 deletion src/Controllers/DatabaseController.js
Original file line number Diff line number Diff line change
Expand Up @@ -428,7 +428,7 @@ class DatabaseController {
if (this.schemaPromise != null) {
return this.schemaPromise;
}
this.schemaPromise = SchemaController.load(this.adapter, options);
this.schemaPromise = SchemaController.load(this.adapter, this.options, options);
this.schemaPromise.then(
() => delete this.schemaPromise,
() => delete this.schemaPromise
Expand Down
9 changes: 3 additions & 6 deletions src/Controllers/SchemaController.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,10 @@
// different databases.
// TODO: hide all schema logic inside the database adapter.
// @flow-disable-next
import Parse from 'parse/node';
import ParseError from '../ParseError';
import { StorageAdapter } from '../Adapters/Storage/StorageAdapter';
import SchemaCache from '../Adapters/Cache/SchemaCache';
import DatabaseController from './DatabaseController';
import Config from '../Config';
// @flow-disable-next
import deepcopy from 'deepcopy';
import type {
Expand Down Expand Up @@ -719,9 +717,8 @@ export default class SchemaController {
protectedFields: any;
userIdRegEx: RegExp;

constructor(databaseAdapter: StorageAdapter) {
constructor(databaseAdapter: StorageAdapter, config) {
this._dbAdapter = databaseAdapter;
const config = Config.get(Parse.applicationId);
this.schemaData = new SchemaData(SchemaCache.all(), this.protectedFields);
this.protectedFields = config.protectedFields;

Expand Down Expand Up @@ -1490,8 +1487,8 @@ export default class SchemaController {
}

// Returns a promise for a new Schema.
const load = (dbAdapter: StorageAdapter, options: any): Promise<SchemaController> => {
const schema = new SchemaController(dbAdapter);
const load = (dbAdapter: StorageAdapter, config, options: any): Promise<SchemaController> => {
const schema = new SchemaController(dbAdapter, config);
ttl.duration = dbAdapter.schemaCacheTtl;
return schema.reloadData(options).then(() => schema);
};
Expand Down
6 changes: 3 additions & 3 deletions src/Controllers/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ interface PushControlling {
}

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

const pushOptions = Object.assign({}, push);
const pushQueueOptions = pushOptions.queueOptions || {};
Expand All @@ -193,10 +193,10 @@ export async function getPushController(options: ParseServerOptions): PushContro

const { disablePushWorker } = pushQueueOptions;

const pushControllerQueue = new PushQueue(pushQueueOptions);
const pushControllerQueue = new PushQueue(pushQueueOptions, appId);
let pushWorker;
if (!disablePushWorker) {
pushWorker = new PushWorker(pushAdapter, pushQueueOptions);
pushWorker = new PushWorker(pushAdapter, pushQueueOptions, appId);
}
return {
pushController,
Expand Down
2 changes: 1 addition & 1 deletion src/ParseServer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ class ParseServer {
await new Promise(resolve => setTimeout(resolve, 10));
}
if (security && security.enableCheck && security.enableCheckLog) {
new CheckRunner(security).run();
new CheckRunner(security).run(undefined, this.config);
}
this.config.state = 'ok';
this.config = { ...this.config, ...pushController };
Expand Down
9 changes: 4 additions & 5 deletions src/Push/PushQueue.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { ParseMessageQueue } from '../ParseMessageQueue';
import rest from '../rest';
import { applyDeviceTokenExists } from './utils';
import Parse from 'parse/node';

const PUSH_CHANNEL = 'parse-server-push';
const DEFAULT_BATCH_SIZE = 100;
Expand All @@ -13,14 +12,14 @@ export class PushQueue {

// config object of the publisher, right now it only contains the redisURL,
// but we may extend it later.
constructor(config: any = {}) {
this.channel = config.channel || PushQueue.defaultPushChannel();
constructor(config: any = {}, applicationId) {
this.channel = config.channel || PushQueue.defaultPushChannel(applicationId);
this.batchSize = config.batchSize || DEFAULT_BATCH_SIZE;
this.parsePublisher = ParseMessageQueue.createPublisher(config);
}

static defaultPushChannel() {
return `${Parse.applicationId}-${PUSH_CHANNEL}`;
static defaultPushChannel(applicationId) {
return `${applicationId}-${PUSH_CHANNEL}`;
}

enqueue(body, where, config, auth, pushStatus) {
Expand Down
4 changes: 2 additions & 2 deletions src/Push/PushWorker.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,11 @@ export class PushWorker {
adapter: any;
channel: string;

constructor(pushAdapter: PushAdapter, subscriberConfig: any = {}) {
constructor(pushAdapter: PushAdapter, subscriberConfig: any = {}, applicationId) {
AdaptableController.validateAdapter(pushAdapter, this, PushAdapter);
this.adapter = pushAdapter;

this.channel = subscriberConfig.channel || PushQueue.defaultPushChannel();
this.channel = subscriberConfig.channel || PushQueue.defaultPushChannel(applicationId);
this.subscriber = ParseMessageQueue.createSubscriber(subscriberConfig);
if (this.subscriber) {
const subscriber = this.subscriber;
Expand Down
2 changes: 1 addition & 1 deletion src/Routers/SecurityRouter.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export class SecurityRouter extends PromiseRouter {
middleware.promiseEnforceMasterKeyAccess,
this._enforceSecurityCheckEnabled,
async req => {
const report = await new CheckRunner(req.config.security).run();
const report = await new CheckRunner(req.config.security).run(undefined, req.config);
return {
status: 200,
response: report,
Expand Down
4 changes: 2 additions & 2 deletions src/Security/CheckGroup.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
* @memberof module:SecurityCheck
*/
class CheckGroup {
constructor() {
constructor(config) {
this._name = this.setName();
this._checks = this.setChecks();
this._checks = this.setChecks(config);
}

/**
Expand Down
5 changes: 1 addition & 4 deletions src/Security/CheckGroups/CheckGroupDatabase.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
import { Check } from '../Check';
import CheckGroup from '../CheckGroup';
import Config from '../../Config';
import Parse from 'parse/node';

/**
* The security checks group for Parse Server configuration.
Expand All @@ -12,8 +10,7 @@ class CheckGroupDatabase extends CheckGroup {
setName() {
return 'Database';
}
setChecks() {
const config = Config.get(Parse.applicationId);
setChecks(config) {
const databaseAdapter = config.database.adapter;
const databaseUrl = databaseAdapter._uri;
return [
Expand Down
5 changes: 1 addition & 4 deletions src/Security/CheckGroups/CheckGroupServerConfig.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
import { Check } from '../Check';
import CheckGroup from '../CheckGroup';
import Config from '../../Config';
import Parse from 'parse/node';

/**
* The security checks group for Parse Server configuration.
Expand All @@ -12,8 +10,7 @@ class CheckGroupServerConfig extends CheckGroup {
setName() {
return 'Parse Server Configuration';
}
setChecks() {
const config = Config.get(Parse.applicationId);
setChecks(config) {
return [
new Check({
title: 'Secure master key',
Expand Down
4 changes: 2 additions & 2 deletions src/Security/CheckRunner.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,11 @@ class CheckRunner {
* @params
* @returns {Object} The security check report.
*/
async run({ version = '1.0.0' } = {}) {
async run({ version = '1.0.0' } = {}, config = {}) {
// Instantiate check groups
const groups = Object.values(this.checkGroups)
.filter(c => typeof c === 'function')
.map(CheckGroup => new CheckGroup());
.map(CheckGroup => new CheckGroup(config));

// Run checks
groups.forEach(group => group.run());
Expand Down
Loading