Programming Standards: Difference between revisions

From Seedbury Square
(.)
No edit summary
Line 29: Line 29:
Por eso in the services should be handled like this:
Por eso in the services should be handled like this:


<pre>
[service]
[service]
     .then((response) => {
     .then((response) => {
Line 37: Line 38:
         // Handle not successful service
         // Handle not successful service
     });
     });
</pre>

Revision as of 17:51, 31 March 2025

Naming Convention

Constants

ROW_VALUE_DESCRIPTION_COLUMN_NAME_TABLE_NAME

COFI

  • ObjectType
- DESCRIPTION_EN_OBJECT_TYPE_CODE
  • [Table]Type
DESCRIPTION_EN_[TABLENAME]_TYPE_CODE
i.e (FileType - MotionType - Code MOTION_FILE_TYPE_CODE)

Handling Service Response

Standards how to handle service response.

SUMAC

Every main in any app will have algo asi:

async request(params, { transition = false, showMsg = true, setStatus = undefined, fullResponse = false } = {}) {
       const serverResponse = await httpRequest(params, setStatus, REQUEST_BRIDGE_SERVICE);
       if (!serverResponse?.success) console.error(serverResponse?.errorMsg ?? 'Backend service NULL');
       return serverResponse?.success
           ? Promise.resolve(fullResponse
               ? serverResponse
               : serverResponse.response)
           : Promise.reject(serverResponse);
   }

Por eso in the services should be handled like this:

[service]
    .then((response) => {
        // Handle successful service
    })
    .catch((err) => {
        console.log("Error: ", err);
        // Handle not successful service
    });