tenant-app-shared-functions
This package content all functions that is used across services in tenant app
Installation
To install, run the code below:
npm install tenant-app-shared-functions
Functions
-
okHttpResponse:
This is use to send ok http response to the client after an operation.
syntax
okHttpResponse(res, response, message='success')
note: res is the express response object while response is the response you want to send to the client. -
errorResponse:
This is use to send Not_found http response to the client after an operation.
syntax
errorResponse(res, message)
note: res is the express response object while message is the message you want to send to the client about the error.
Example 1:
(req, res) => {
try {
doSomething();
okHttpResponse(res, response);
}
catch (e) {
errorResponse(res, e.message)
}
}
Example 2:
(req, res) => {
try {
doSomething();
okHttpResponse(
res,
response,
'operation was successful'
);
}
catch (e) {
errorResponse(res, e.message)
}
}