-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #16 from trygve-lie/refined-status-codes
Refine which http status codes to trip on
- Loading branch information
Showing
18 changed files
with
393 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
'use strict'; | ||
|
||
module.exports = (res = {}) => { | ||
if (res.statusCode === undefined) { | ||
return true; | ||
} | ||
|
||
let result = false; | ||
switch (res.statusCode) { | ||
case 408: // Request Timeout | ||
result = true; | ||
break; | ||
|
||
case 413: // Payload Too Large | ||
result = true; | ||
break; | ||
|
||
case 429: // Too Many Requests | ||
result = true; | ||
break; | ||
|
||
case 500: // Internal Server Error | ||
result = true; | ||
break; | ||
|
||
case 502: // Bad Gateway | ||
result = true; | ||
break; | ||
|
||
case 503: // Service Unavailable | ||
result = true; | ||
break; | ||
|
||
case 504: // Gateway Timeout | ||
result = true; | ||
break; | ||
|
||
default: | ||
result = false; | ||
} | ||
|
||
return result; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
'use strict'; | ||
|
||
const isFunction = (fn) => { | ||
const type = {}.toString.call(fn); | ||
return type === '[object Function]' || type === '[object AsyncFunction]'; | ||
}; | ||
module.exports.isFunction = isFunction; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.