README
Worksignal Element: el-response
What is Worksignal?
Worksignal is a business platform which accepts adding components from npm website.
What is this package?
This package is a simple class to make a standard response by Worksignal backend services.
How to import it
Use this command to import el-response into any of Worksignal backend projects.
npm instal el-response
How prepare the response
The response is an array of CallResult objects. Call CallResult class has the following properties:
class CallResult {
isSuccessful: boolean;
message: string;
issue: TechnicalIssue; // null if isSuccessful is true
result: any;
}
If your service only has one object still need to prepare a single element array so that the response can be prepared correctly. Let's say your method recieves an UserID and will return the user profile. If the call is successful you can put the profile object in result propery and set the isSuccessful flag to true. You can alse return a message of your choice. However if for example you did not find the record you should set the issue with a Technical issue object.
TechnicalIssue is a simple class with only two properties:
- message: report of the problem technically explained
- error: an error/exception object or anything else.