Programming Standards: Difference between revisions
(→SUMAC) |
(→SUMAC) |
||
| Line 16: | Line 16: | ||
=== [https://wiki.seedburysquare.com/index.php/Sistema_Unificado_de_Manejo_y_Administraci%C3%B3n_de_Casos SUMAC] === | === [https://wiki.seedburysquare.com/index.php/Sistema_Unificado_de_Manejo_y_Administraci%C3%B3n_de_Casos SUMAC] === | ||
Every main in any app will have algo asi: | Every main in any app will have algo asi: | ||
<pre> | <pre><nowiki> | ||
async request(params, { transition = false, showMsg = true, setStatus = undefined, fullResponse = false } = {}) { | async request(params, { transition = false, showMsg = true, setStatus = undefined, fullResponse = false } = {}) { | ||
const serverResponse = await httpRequest(params, setStatus, REQUEST_BRIDGE_SERVICE); | const serverResponse = await httpRequest(params, setStatus, REQUEST_BRIDGE_SERVICE); | ||
| Line 26: | Line 26: | ||
: Promise.reject(serverResponse); | : Promise.reject(serverResponse); | ||
} | } | ||
</pre> | </nowiki></pre> | ||
Por eso in the services should be handled like this: | Por eso in the services should be handled like this: | ||
Revision as of 18:05, 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
});