From c29717334e71a09a8e9ea5132d2c7448e4435e2c Mon Sep 17 00:00:00 2001 From: Manuel Trezza Date: Tue, 15 Dec 2020 15:27:22 +0100 Subject: [PATCH 1/3] add Parse Error guide --- CONTRIBUTING.md | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 6c2ccd3bd8..c97ae86fa1 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -111,6 +111,26 @@ For example, allowing public read and write to a class may be useful to simplify Security checks are added in [SecurityChecks.js](https://github.com/parse-community/parse-server/blob/master/src/SecurityChecks.js). +### Parse Error + +Introducing new Parse Errors requires the following steps: + +1. Research whether an existing Parse Error already covers the error scenario. Keep in mind that reusing an already existing Parse Error does not allow to distinguish between scenarios in which the same error is thrown, so it may be necessary to add a new and more specific Parse Error, eventhough an more general Parse Error already exists. +⚠️ Currently (as of Dec. 2020), there are inconsistencies between the Parse Errors documented in the Parse Guides, coded in the Parse JS SDK and coded in Parse Server, therefore research regarding the availability of error codes has to be conducted in all of these sources. +1. Add the new Parse Error to [/src/ParseError.js](https://github.com/parse-community/Parse-SDK-JS/blob/master/src/ParseError.js) in the Parse JavaScript SDK. This is the primary reference for Parse Errors for the Parse JavaScript SDK and Parse Server. +1. Create a pull request for the Parse JavaScript SDK including the new Parse Errors. The PR needs to be merged and a new Parse JS SDK version needs to be released. +1. Change the Parse JS SDK dependency in [package.json](https://github.com/parse-community/parse-server/blob/master/package.json) of Parse Server to the newly released Parse JS SDK version, so that the new Parse Error is recognized by Parse Server. +1. When throwing the new Parse Error in code, do not hard-code the error code but instead reference the error code from the Parse Error. For example: + ```javascript + throw new Parse.Error(Parse.Error.EXAMPLE_ERROR_CODE, 'Example error message.'); + ``` +1. Choose a descriptive error message that provdes more details about the specific error scenario. Different error messages may be used for the same error code. For example: + ```javascript + throw new Parse.Error(Parse.Error.FILE_SAVE_ERROR, 'The file could not be saved because it exceeded the maximum allowed file size.'); + throw new Parse.Error(Parse.Error.FILE_SAVE_ERROR, 'The file could not be saved because the file format was incorrect.'); + ``` +1. Add the new Parse Error to the [docs](https://github.com/parse-community/docs/blob/gh-pages/_includes/common/errors.md). + ## Code of Conduct This project adheres to the [Contributor Covenant Code of Conduct](https://github.com/parse-community/parse-server/blob/master/CODE_OF_CONDUCT.md). By participating, you are expected to honor this code. From 128bf026545ca4ee9c6938a4641ad3adaa2d62d0 Mon Sep 17 00:00:00 2001 From: Manuel Trezza Date: Tue, 15 Dec 2020 15:27:39 +0100 Subject: [PATCH 2/3] add Parse Server config guide --- CONTRIBUTING.md | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index c97ae86fa1..962cf7b773 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -131,6 +131,16 @@ Introducing new Parse Errors requires the following steps: ``` 1. Add the new Parse Error to the [docs](https://github.com/parse-community/docs/blob/gh-pages/_includes/common/errors.md). +### Parse Server Configuration + +Introducing new Parse Server configuration parameters requires the following steps: + +1. Add parameters definitions in [/src/Options/index.js](https://github.com/parse-community/parse-server/blob/master/src/Options/index.js). +1. If a nested configuration object has been added, add the environment variable option prefix to `getENVPrefix` in [/resources/buildConfigDefinition.js](https://github.com/parse-community/parse-server/blob/master/resources/buildConfigDefinition.js). +1. Execute `npm run definitions` to automatically create the definitions in [/src/Options/Definitions.js](https://github.com/parse-community/parse-server/blob/master/src/Options/Definitions.js). +1. Add parameter value validation in [/src/Config.js](https://github.com/parse-community/parse-server/blob/master/src/Config.js). +1. Add test cases to ensure the correct parameter value validation. Parse Server throws an error at launch if an invalid value is set for any configuration parameter. + ## Code of Conduct This project adheres to the [Contributor Covenant Code of Conduct](https://github.com/parse-community/parse-server/blob/master/CODE_OF_CONDUCT.md). By participating, you are expected to honor this code. From a1931a1d0441c2693aece532c0a30228184bd457 Mon Sep 17 00:00:00 2001 From: Manuel Trezza Date: Tue, 15 Dec 2020 16:10:20 +0100 Subject: [PATCH 3/3] removed old instructions for adding config parameters --- CONTRIBUTING.md | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 962cf7b773..e507ade035 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -94,12 +94,6 @@ RUN chmod +x /docker-entrypoint-initdb.d/setup-dbs.sh Note that the script above will ONLY be executed during initialization of the container with no data in the database, see the official [Postgres image](https://hub.docker.com/_/postgres) for details. If you want to use the script to run again be sure there is no data in the /var/lib/postgresql/data of the container. -### Generate Parse Server Config Definition - -If you want to make changes to [Parse Server Configuration][config] add the desired configuration to [src/Options/index.js][config-index] and run `npm run definitions`. This will output [src/Options/Definitions.js][config-def] and [src/Options/docs.js][config-docs]. - -To view docs run `npm run docs` and check the `/out` directory. - ## Feature Considerations ### Security Checks @@ -133,13 +127,14 @@ Introducing new Parse Errors requires the following steps: ### Parse Server Configuration -Introducing new Parse Server configuration parameters requires the following steps: +Introducing new [Parse Server configuration][config] parameters requires the following steps: -1. Add parameters definitions in [/src/Options/index.js](https://github.com/parse-community/parse-server/blob/master/src/Options/index.js). +1. Add parameters definitions in [/src/Options/index.js][config-index]. 1. If a nested configuration object has been added, add the environment variable option prefix to `getENVPrefix` in [/resources/buildConfigDefinition.js](https://github.com/parse-community/parse-server/blob/master/resources/buildConfigDefinition.js). -1. Execute `npm run definitions` to automatically create the definitions in [/src/Options/Definitions.js](https://github.com/parse-community/parse-server/blob/master/src/Options/Definitions.js). +1. Execute `npm run definitions` to automatically create the definitions in [/src/Options/Definitions.js][config-def] and [/src/Options/docs.js][config-docs]. 1. Add parameter value validation in [/src/Config.js](https://github.com/parse-community/parse-server/blob/master/src/Config.js). 1. Add test cases to ensure the correct parameter value validation. Parse Server throws an error at launch if an invalid value is set for any configuration parameter. +1. Execute `npm run docs` to generate the documentation in the `/out` directory. Take a look at the documentation whether the description and formatting of the newly introduced parameters is satisfactory. ## Code of Conduct