module-connector
Advanced tools
Comparing version 1.0.1 to 1.0.2
@@ -19,8 +19,8 @@ 'use strict' | ||
/** @integer HTTP code response */ | ||
this.code = 500; | ||
/** @obj || @array content of response*/ | ||
this.response = []; | ||
/** @integer HTTP code response */ | ||
this.code = 500; | ||
Object.preventExtensions(this); | ||
@@ -27,0 +27,0 @@ }; |
{ | ||
"name": "module-connector", | ||
"version": "1.0.1", | ||
"version": "1.0.2", | ||
"description": "object used to connect different backend and frontend components. in order to better control the different scenarios that could occur with the communication of these", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
# module-connector | ||
object used to connect different backend and frontend components. in order to better control the different scenarios that could occur with the communication of these | ||
object used to connect different backend and frontend components. in order to better control the different scenarios that could occur with the communication of these | ||
## structure | ||
| Attribute | Type | Default | Description | | ||
| ------------- | :-------------: | :-------------: | ------------- | | ||
| success | boolean | false | tells us if the process that the component is in charge of is completed successfully or not | | ||
| message | string | module_connector | a message is left here depending on the conclusion of the component. for example: created_user, existing_name, id_no_found | | ||
| response | array / object | [] | All the content that should come from the component is sent here, it can be a list, an element as such, but never a string, boolean or integer value, for reasons of scalability | | ||
| code | integer | 500 | HTTP code | | ||
## example | ||
although the component is called a module connector. The most recommended is to define a variable with the name of output when creating a new connector, since it is more readable. it is also recommended to define it as let so that it never deceives us with other classes, functions or services | ||
```javascript | ||
//include library | ||
let moduleConnector = require("module-connector"); | ||
//create default output from module connector | ||
let output = new moduleConnector(); | ||
//you code | ||
let arrayClientList = [ | ||
{ id:1, name: "diana" }, | ||
{ id:2, name: "jorge" } | ||
]; | ||
//modify output | ||
output.success = true; | ||
output.message = "array_clients_list"; | ||
output.code = 200; | ||
output.response = arrayClientList; | ||
//return output | ||
return output; | ||
``` |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
4102
43