playov2-js-utilities 0.3.59 → 0.3.61
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -21,6 +21,16 @@ const Logger = require('../logger.js');
|
|
|
21
21
|
* @returns
|
|
22
22
|
*/
|
|
23
23
|
const playoResponseHandler = (resp, requestId) => {
|
|
24
|
+
|
|
25
|
+
if(!resp) {
|
|
26
|
+
resp = {
|
|
27
|
+
isAxiosError: true,
|
|
28
|
+
code: "NO_RESPONSE",
|
|
29
|
+
message: "No response from the service",
|
|
30
|
+
data : {requestStatus: 0}
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
|
|
24
34
|
if (resp.isAxiosError) {
|
|
25
35
|
//if axios error is triggered then axios throws HTTP code for timeout or other forms of unsuccessful errors
|
|
26
36
|
const {
|
|
@@ -74,7 +84,7 @@ const get = async (url, headers = {}, query = {}, requestId = '', responseHandle
|
|
|
74
84
|
const resp = await Axios.get(url, { headers, params: query, timeout });
|
|
75
85
|
return responseHandler(resp, requestId, apiName);
|
|
76
86
|
} catch (error) {
|
|
77
|
-
Logger.prepareErrorLog(requestId, { url, headers, query
|
|
87
|
+
Logger.prepareErrorLog(requestId, { url, headers, query }, `Api call to url to ${url} failed!`);
|
|
78
88
|
return responseHandler(error.response, requestId, apiName);
|
|
79
89
|
}
|
|
80
90
|
};
|
|
@@ -96,7 +106,7 @@ const post = async (url, headers = {}, query = {}, body = {}, requestId = '', re
|
|
|
96
106
|
const resp = await Axios.post(url, body, options);
|
|
97
107
|
return responseHandler(resp, requestId, apiName);
|
|
98
108
|
} catch (error) {
|
|
99
|
-
Logger.prepareErrorLog(requestId, { url, headers, query, body
|
|
109
|
+
Logger.prepareErrorLog(requestId, { url, headers, query, body }, `Api call to url to ${url} failed due to ${error.response.message}`);
|
|
100
110
|
return responseHandler(error.response, requestId, apiName);
|
|
101
111
|
}
|
|
102
112
|
};
|
|
@@ -118,7 +128,7 @@ const put = async (url, headers = {}, query = {}, body = {}, requestId = '', res
|
|
|
118
128
|
const resp = await Axios.put(url, body, options);
|
|
119
129
|
return responseHandler(resp, requestId, apiName);
|
|
120
130
|
} catch (error) {
|
|
121
|
-
Logger.prepareErrorLog(requestId, { url, headers, query, body
|
|
131
|
+
Logger.prepareErrorLog(requestId, { url, headers, query, body }, `Api call to url to ${url} failed due to ${error.response.message}`);
|
|
122
132
|
return responseHandler(error.response, requestId, apiName);
|
|
123
133
|
}
|
|
124
134
|
};
|
|
@@ -140,7 +150,7 @@ const remove = async (url, headers = {}, query = {}, body, requestId = '', respo
|
|
|
140
150
|
const resp = await Axios.delete(url, options);
|
|
141
151
|
return responseHandler(resp, requestId);
|
|
142
152
|
} catch (error) {
|
|
143
|
-
Logger.prepareErrorLog(requestId, { url, headers, query, body
|
|
153
|
+
Logger.prepareErrorLog(requestId, { url, headers, query, body }, `Api call to url to ${url} failed due to ${error.response.message}`);
|
|
144
154
|
return responseHandler(error.response, requestId, apiName);
|
|
145
155
|
}
|
|
146
156
|
};
|
|
@@ -3,7 +3,7 @@ const Filter = require("bad-words");
|
|
|
3
3
|
const profanityFilter = new Filter();
|
|
4
4
|
const profanityWordList = profanityWords.split(",");
|
|
5
5
|
|
|
6
|
-
const excludeWords = ['swastik', 'swastika'];
|
|
6
|
+
const excludeWords = ['swastik', 'swastika', 'islam'];
|
|
7
7
|
|
|
8
8
|
profanityFilter.addWords(...profanityWordList);
|
|
9
9
|
profanityFilter.removeWords(...excludeWords)
|