mythix 2.8.6 → 2.8.8

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mythix",
3
- "version": "2.8.6",
3
+ "version": "2.8.8",
4
4
  "description": "Mythix is a NodeJS web-app framework",
5
5
  "main": "src/index",
6
6
  "scripts": {
@@ -108,42 +108,25 @@ function nodeRequestHandler(routeName, requestOptions) {
108
108
  response.on('end', function() {
109
109
  response.rawBody = response.body = responseData;
110
110
 
111
+ if (response.statusCode > 399) {
112
+ var error = new Error(response.statusText);
113
+ error.response = response;
114
+
115
+ reject(error);
116
+ return;
117
+ }
118
+
111
119
  try {
112
120
  var contentType = response.headers['content-type'];
113
121
 
114
122
  if (contentType && contentType.match(/application\/json/i)) {
115
123
  var data = JSON.parse(responseData.toString('utf8'));
116
-
117
- Object.defineProperties(data, {
118
- '__response': {
119
- writable: true,
120
- enumerable: false,
121
- configurable: true,
122
- value: response,
123
- },
124
- '__statusCode': {
125
- writable: true,
126
- enumerable: false,
127
- configurable: true,
128
- value: response.status,
129
- },
130
- '__statusText': {
131
- writable: true,
132
- enumerable: false,
133
- configurable: true,
134
- value: response.statusText,
135
- },
136
- });
137
-
138
124
  response.body = data;
139
-
140
- resolve(data);
141
125
  } else if (contentType && contentType.match(/text\/(plain|html)/)) {
142
126
  response.body = responseData.toString('utf8');
143
- resolve(response.body);
144
- } else {
145
- resolve(response);
146
127
  }
128
+
129
+ resolve(response);
147
130
  } catch (error) {
148
131
  return reject(error);
149
132
  }
@@ -215,7 +198,7 @@ function browserRequestHandler(routeName, requestOptions) {
215
198
  if (typeof requestOptions.responseHandler === 'function')
216
199
  return requestOptions.responseHandler(response);
217
200
 
218
- if (!response.ok) {
201
+ if (!response.ok || response.statusCode > 399) {
219
202
  var error = new Error(response.statusText);
220
203
  error.response = response;
221
204
 
@@ -226,34 +209,12 @@ function browserRequestHandler(routeName, requestOptions) {
226
209
  var contentType = response.headers.get('Content-Type');
227
210
  if (contentType && contentType.match(/application\/json/i)) {
228
211
  var data = response.json();
229
-
230
- Object.defineProperties(data, {
231
- '__response': {
232
- writable: true,
233
- enumerable: false,
234
- configurable: true,
235
- value: response,
236
- },
237
- '__statusCode': {
238
- writable: true,
239
- enumerable: false,
240
- configurable: true,
241
- value: response.status,
242
- },
243
- '__statusText': {
244
- writable: true,
245
- enumerable: false,
246
- configurable: true,
247
- value: response.statusText,
248
- },
249
- });
250
-
251
- resolve(data);
212
+ response.body = data;
252
213
  } else if (contentType && contentType.match(/text\/(plain|html)/i)) {
253
- resolve(response.text());
254
- } else {
255
- resolve(response);
214
+ response.body = response.text();
256
215
  }
216
+
217
+ resolve(response);
257
218
  },
258
219
  function(error) {
259
220
  reject(error);
@@ -27,7 +27,7 @@ function walkDir(rootPath, _options, _callback, _allFiles, _depth) {
27
27
 
28
28
  if (typeof filterFunc === 'function' && !filterFunc(fullFileName, fileName, stats, rootPath, depth))
29
29
  continue;
30
- else if (filterFunc instanceof RegExp && !filterFunc.match(fullFileName))
30
+ else if (filterFunc instanceof RegExp && !fullFileName.match(filterFunc))
31
31
  continue;
32
32
 
33
33