Skip to content

Commit 42696e9

Browse files
committed
Fix code review issues
1 parent aa9b15e commit 42696e9

File tree

7 files changed

+12
-33
lines changed

7 files changed

+12
-33
lines changed

spec/DefinedSchemas.spec.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -545,13 +545,13 @@ fdescribe('DefinedSchemas', () => {
545545
try {
546546
await new Parse.Schema('Test').save();
547547
} catch (e) {
548-
expect(e.message).toContain('cannot perform this operation when schemas options is used.');
548+
expect(e.message).toContain('Cannot perform this operation when schemas options is used.');
549549
}
550550

551551
try {
552552
await new Parse.Schema('_User').update();
553553
} catch (e) {
554-
expect(e.message).toContain('cannot perform this operation when schemas options is used.');
554+
expect(e.message).toContain('Cannot perform this operation when schemas options is used.');
555555
}
556556
});
557557
it('should only enable delete class endpoint since', async () => {

src/Options/Definitions.js

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -52,11 +52,6 @@ module.exports.ParseServerOptions = {
5252
'Configuration for your authentication providers, as stringified JSON. See http://docs.parseplatform.org/parse-server/guide/#oauth-and-3rd-party-authentication',
5353
action: parsers.objectParser,
5454
},
55-
beforeSchemasMigration: {
56-
env: 'PARSE_SERVER_BEFORE_SCHEMAS_MIGRATION',
57-
help:
58-
'Callback when server has started and before running schemas migration operations if schemas key provided',
59-
},
6055
cacheAdapter: {
6156
env: 'PARSE_SERVER_CACHE_ADAPTER',
6257
help: 'Adapter module for the cache',
@@ -365,12 +360,6 @@ module.exports.ParseServerOptions = {
365360
action: parsers.booleanParser,
366361
default: false,
367362
},
368-
schemas: {
369-
env: 'PARSE_SERVER_SCHEMAS',
370-
help:
371-
'Rest representation on Parse.Schema https://docs.parseplatform.org/rest/guide/#adding-a-schema',
372-
action: parsers.arrayParser,
373-
},
374363
security: {
375364
env: 'PARSE_SERVER_SECURITY',
376365
help: 'The security options to identify and report weak security settings.',
@@ -564,8 +553,6 @@ module.exports.PagesCustomUrlsOptions = {
564553
help: 'The URL to the custom page for password reset -> success.',
565554
},
566555
};
567-
module.exports.FieldType = {};
568-
module.exports.JSONSchema = {};
569556
module.exports.CustomPagesOptions = {
570557
choosePassword: {
571558
env: 'PARSE_SERVER_CUSTOM_PAGES_CHOOSE_PASSWORD',

src/Options/index.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -242,8 +242,6 @@ export interface ParseServerOptions {
242242
playgroundPath: ?string;
243243
/* Callback when server has started */
244244
serverStartComplete: ?(error: ?Error) => void;
245-
/* Callback when server has started and before running schemas migration operations if schemas key provided */
246-
beforeSchemasMigration: ?() => void | Promise<void>;
247245
/* Rest representation on Parse.Schema https://docs.parseplatform.org/rest/guide/#adding-a-schema */
248246
migrations: ?MigrationsOptions;
249247
/* Callback when server has closed */

src/ParseServer.js

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,6 @@ class ParseServer {
6969
javascriptKey,
7070
serverURL = requiredParameter('You must provide a serverURL!'),
7171
serverStartComplete,
72-
beforeSchemasMigration,
7372
migrations,
7473
} = options;
7574
// Initialize the node client SDK automatically
@@ -88,9 +87,6 @@ class ParseServer {
8887
.performInitialization()
8988
.then(() => hooksController.load())
9089
.then(async () => {
91-
if (beforeSchemasMigration) {
92-
await Promise.resolve(beforeSchemasMigration());
93-
}
9490
if (migrations) {
9591
await new DefinedSchemas(migrations, this.config).execute();
9692
}

src/Routers/SchemasRouter.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ const checkIfDefinedSchemasIsUsed = req => {
4444
) {
4545
throw new Parse.Error(
4646
Parse.Error.OPERATION_FORBIDDEN,
47-
'cannot perform this operation when schemas options is used.'
47+
'Cannot perform this operation when schemas options is used.'
4848
);
4949
}
5050
};

src/SchemaMigrations/DefinedSchemas.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
1; // @flow
2-
// import Parse from 'parse/node';
1+
// @flow
32
const Parse = require('parse/node');
43
import { logger } from '../logger';
54
import Config from '../Config';
@@ -68,6 +67,9 @@ export class DefinedSchemas {
6867
let timeout = null;
6968
try {
7069
logger.info('Running Migrations');
70+
if (this.migrationsOptions && this.migrationsOptions.beforeSchemasMigration) {
71+
await Promise.resolve(this.migrationsOptions.beforeSchemasMigration());
72+
}
7173
// Set up a time out in production
7274
// if we fail to get schema
7375
// pm2 or K8s and many other process managers will try to restart the process

src/SchemaMigrations/Migrations.js

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -39,15 +39,11 @@ export interface MigrationsOptions {
3939
strict: ?boolean;
4040
deleteExtraFields: ?boolean;
4141
recreateModifiedFields: ?boolean;
42+
/* Callback when server has started and before running schemas migration operations if schemas key provided */
43+
beforeSchemasMigration: ?() => void | Promise<void>;
4244
}
4345

44-
export type CLPOperation =
45-
| 'find'
46-
| 'count'
47-
| 'get'
48-
| 'update'
49-
| 'create'
50-
| 'delete' /*| 'addField'*/;
46+
export type CLPOperation = 'find' | 'count' | 'get' | 'update' | 'create' | 'delete';
5147
// @Typescript 4.1+ // type CLPPermission = 'requiresAuthentication' | '*' | `user:${string}` | `role:${string}`
5248

5349
type CLPValue = { [key: string]: boolean };
@@ -87,8 +83,8 @@ export class CLP {
8783

8884
export function makeSchema(className: ClassNameType, schema: JSONSchema): JSONSchema {
8985
// This function solve two things:
90-
// 1. It provide auto-completion to the users who are implementing schemas
91-
// 2. It allow forward-compatible point in order to allow future changes to the internal structure of JSONSchema without affecting all the users
86+
// 1. It provides auto-completion to the users who are implementing schemas
87+
// 2. It allows forward-compatible point in order to allow future changes to the internal structure of JSONSchema without affecting all the users
9288

9389
return {
9490
className,

0 commit comments

Comments
 (0)