Update index.js

- increased timeout up to 60 seconds
- changed valid response status code range
- removed errors type check
This commit is contained in:
freearhey 2019-09-08 15:43:45 +03:00
parent aad7f1c83d
commit aea1f081c6
1 changed files with 4 additions and 8 deletions

View File

@ -5,7 +5,7 @@ const https = require('https')
const verbose = process.env.npm_config_debug || false const verbose = process.env.npm_config_debug || false
const errorLog = 'error.log' const errorLog = 'error.log'
const config = { const config = {
timeout: 1000, timeout: 60000,
delay: 200 delay: 200
} }
@ -21,7 +21,7 @@ const instance = axios.create({
rejectUnauthorized: false rejectUnauthorized: false
}), }),
validateStatus: function (status) { validateStatus: function (status) {
return status >= 200 && status < 404 return status >= 200 && status < 400
}, },
headers: { headers: {
'Accept': '*/*', 'Accept': '*/*',
@ -81,8 +81,6 @@ async function test() {
} catch (err) { } catch (err) {
if(err.response || (err.request && ['ENOTFOUND'].indexOf(err.code) > -1)) {
stats.failures++ stats.failures++
writeToLog(country.url, err.message, item.url) writeToLog(country.url, err.message, item.url)
@ -90,8 +88,6 @@ async function test() {
} }
} }
}
} }
if(stats.failures === 0) { if(stats.failures === 0) {