Skip to content

Commit ff4913c

Browse files
committed
Remove circular dependency
1 parent 2c89746 commit ff4913c

12 files changed

+21
-32
lines changed

src/ClientSDK.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@ module.exports = {
4040
Object: Parse.Object,
4141
Query: Parse.Query,
4242
Schema: Parse.Schema,
43-
User: Parse.User,
4443
compatible,
4544
supportsForwardDelete,
4645
fromString,

src/Controllers/DatabaseController.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -428,7 +428,7 @@ class DatabaseController {
428428
if (this.schemaPromise != null) {
429429
return this.schemaPromise;
430430
}
431-
this.schemaPromise = SchemaController.load(this.adapter, options);
431+
this.schemaPromise = SchemaController.load(this.adapter, this.options, options);
432432
this.schemaPromise.then(
433433
() => delete this.schemaPromise,
434434
() => delete this.schemaPromise

src/Controllers/SchemaController.js

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,10 @@
1515
// different databases.
1616
// TODO: hide all schema logic inside the database adapter.
1717
// @flow-disable-next
18-
import Parse from 'parse/node';
1918
import ParseError from '../ParseError';
2019
import { StorageAdapter } from '../Adapters/Storage/StorageAdapter';
2120
import SchemaCache from '../Adapters/Cache/SchemaCache';
2221
import DatabaseController from './DatabaseController';
23-
import Config from '../Config';
2422
// @flow-disable-next
2523
import deepcopy from 'deepcopy';
2624
import type {
@@ -719,9 +717,8 @@ export default class SchemaController {
719717
protectedFields: any;
720718
userIdRegEx: RegExp;
721719

722-
constructor(databaseAdapter: StorageAdapter) {
720+
constructor(databaseAdapter: StorageAdapter, config) {
723721
this._dbAdapter = databaseAdapter;
724-
const config = Config.get(Parse.applicationId);
725722
this.schemaData = new SchemaData(SchemaCache.all(), this.protectedFields);
726723
this.protectedFields = config.protectedFields;
727724

@@ -1490,8 +1487,8 @@ export default class SchemaController {
14901487
}
14911488

14921489
// Returns a promise for a new Schema.
1493-
const load = (dbAdapter: StorageAdapter, options: any): Promise<SchemaController> => {
1494-
const schema = new SchemaController(dbAdapter);
1490+
const load = (dbAdapter: StorageAdapter, config, options: any): Promise<SchemaController> => {
1491+
const schema = new SchemaController(dbAdapter, config);
14951492
ttl.duration = dbAdapter.schemaCacheTtl;
14961493
return schema.reloadData(options).then(() => schema);
14971494
};

src/Controllers/index.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ interface PushControlling {
170170
}
171171

172172
export async function getPushController(options: ParseServerOptions): PushControlling {
173-
const { scheduledPush, push } = options;
173+
const { scheduledPush, push, appId } = options;
174174

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

194194
const { disablePushWorker } = pushQueueOptions;
195195

196-
const pushControllerQueue = new PushQueue(pushQueueOptions);
196+
const pushControllerQueue = new PushQueue(pushQueueOptions, appId);
197197
let pushWorker;
198198
if (!disablePushWorker) {
199-
pushWorker = new PushWorker(pushAdapter, pushQueueOptions);
199+
pushWorker = new PushWorker(pushAdapter, pushQueueOptions, appId);
200200
}
201201
return {
202202
pushController,

src/ParseServer.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,7 @@ class ParseServer {
202202
await new Promise(resolve => setTimeout(resolve, 10));
203203
}
204204
if (security && security.enableCheck && security.enableCheckLog) {
205-
new CheckRunner(security).run();
205+
new CheckRunner(security).run(undefined, this.config);
206206
}
207207
this.config.state = 'ok';
208208
this.config = { ...this.config, ...pushController };

src/Push/PushQueue.js

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import { ParseMessageQueue } from '../ParseMessageQueue';
22
import rest from '../rest';
33
import { applyDeviceTokenExists } from './utils';
4-
import Parse from 'parse/node';
54

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

1413
// config object of the publisher, right now it only contains the redisURL,
1514
// but we may extend it later.
16-
constructor(config: any = {}) {
17-
this.channel = config.channel || PushQueue.defaultPushChannel();
15+
constructor(config: any = {}, applicationId) {
16+
this.channel = config.channel || PushQueue.defaultPushChannel(applicationId);
1817
this.batchSize = config.batchSize || DEFAULT_BATCH_SIZE;
1918
this.parsePublisher = ParseMessageQueue.createPublisher(config);
2019
}
2120

22-
static defaultPushChannel() {
23-
return `${Parse.applicationId}-${PUSH_CHANNEL}`;
21+
static defaultPushChannel(applicationId) {
22+
return `${applicationId}-${PUSH_CHANNEL}`;
2423
}
2524

2625
enqueue(body, where, config, auth, pushStatus) {

src/Push/PushWorker.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,11 @@ export class PushWorker {
2626
adapter: any;
2727
channel: string;
2828

29-
constructor(pushAdapter: PushAdapter, subscriberConfig: any = {}) {
29+
constructor(pushAdapter: PushAdapter, subscriberConfig: any = {}, applicationId) {
3030
AdaptableController.validateAdapter(pushAdapter, this, PushAdapter);
3131
this.adapter = pushAdapter;
3232

33-
this.channel = subscriberConfig.channel || PushQueue.defaultPushChannel();
33+
this.channel = subscriberConfig.channel || PushQueue.defaultPushChannel(applicationId);
3434
this.subscriber = ParseMessageQueue.createSubscriber(subscriberConfig);
3535
if (this.subscriber) {
3636
const subscriber = this.subscriber;

src/Routers/SecurityRouter.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ export class SecurityRouter extends PromiseRouter {
1010
middleware.promiseEnforceMasterKeyAccess,
1111
this._enforceSecurityCheckEnabled,
1212
async req => {
13-
const report = await new CheckRunner(req.config.security).run();
13+
const report = await new CheckRunner(req.config.security).run(undefined, req.config);
1414
return {
1515
status: 200,
1616
response: report,

src/Security/CheckGroup.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@
44
* @memberof module:SecurityCheck
55
*/
66
class CheckGroup {
7-
constructor() {
7+
constructor(config) {
88
this._name = this.setName();
9-
this._checks = this.setChecks();
9+
this._checks = this.setChecks(config);
1010
}
1111

1212
/**

src/Security/CheckGroups/CheckGroupDatabase.js

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
import { Check } from '../Check';
22
import CheckGroup from '../CheckGroup';
3-
import Config from '../../Config';
4-
import Parse from 'parse/node';
53

64
/**
75
* The security checks group for Parse Server configuration.
@@ -12,8 +10,7 @@ class CheckGroupDatabase extends CheckGroup {
1210
setName() {
1311
return 'Database';
1412
}
15-
setChecks() {
16-
const config = Config.get(Parse.applicationId);
13+
setChecks(config) {
1714
const databaseAdapter = config.database.adapter;
1815
const databaseUrl = databaseAdapter._uri;
1916
return [

src/Security/CheckGroups/CheckGroupServerConfig.js

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
import { Check } from '../Check';
22
import CheckGroup from '../CheckGroup';
3-
import Config from '../../Config';
4-
import Parse from 'parse/node';
53

64
/**
75
* The security checks group for Parse Server configuration.
@@ -12,8 +10,7 @@ class CheckGroupServerConfig extends CheckGroup {
1210
setName() {
1311
return 'Parse Server Configuration';
1412
}
15-
setChecks() {
16-
const config = Config.get(Parse.applicationId);
13+
setChecks(config) {
1714
return [
1815
new Check({
1916
title: 'Secure master key',

src/Security/CheckRunner.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,11 @@ class CheckRunner {
2929
* @params
3030
* @returns {Object} The security check report.
3131
*/
32-
async run({ version = '1.0.0' } = {}) {
32+
async run({ version = '1.0.0' } = {}, config = {}) {
3333
// Instantiate check groups
3434
const groups = Object.values(this.checkGroups)
3535
.filter(c => typeof c === 'function')
36-
.map(CheckGroup => new CheckGroup());
36+
.map(CheckGroup => new CheckGroup(config));
3737

3838
// Run checks
3939
groups.forEach(group => group.run());

0 commit comments

Comments
 (0)