Make certain fetchers environment-aware

This commit is contained in:
Yarmo Mackenbach 2021-04-26 12:11:14 +02:00
parent ffbae32a55
commit e13bd4e9f5
No known key found for this signature in database
GPG key ID: 37367F4AF4087AD1
3 changed files with 28 additions and 7 deletions

View file

@ -13,7 +13,7 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and See the License for the specific language governing permissions and
limitations under the License. limitations under the License.
*/ */
const dns = require('dns') const jsEnv = require("browser-or-node")
/** /**
* @module fetcher/dns * @module fetcher/dns
@ -25,6 +25,13 @@ const dns = require('dns')
*/ */
module.exports.timeout = 5000 module.exports.timeout = 5000
if (!jsEnv.isNode) {
module.exports.fn = null
return
}
const dns = require('dns')
/** /**
* Execute a fetch request * Execute a fetch request
* @function * @function

View file

@ -13,8 +13,7 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and See the License for the specific language governing permissions and
limitations under the License. limitations under the License.
*/ */
const irc = require('irc-upd') const jsEnv = require("browser-or-node")
const validator = require('validator')
/** /**
* @module fetcher/irc * @module fetcher/irc
@ -26,6 +25,14 @@ const validator = require('validator')
*/ */
module.exports.timeout = 20000 module.exports.timeout = 20000
if (!jsEnv.isNode) {
module.exports.fn = null
return
}
const irc = require('irc-upd')
const validator = require('validator')
/** /**
* Execute a fetch request * Execute a fetch request
* @function * @function

View file

@ -13,10 +13,7 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and See the License for the specific language governing permissions and
limitations under the License. limitations under the License.
*/ */
const jsdom = require('jsdom') const jsEnv = require("browser-or-node")
const { client, xml } = require('@xmpp/client')
const debug = require('@xmpp/debug')
const validator = require('validator')
/** /**
* @module fetcher/xmpp * @module fetcher/xmpp
@ -28,6 +25,16 @@ const validator = require('validator')
*/ */
module.exports.timeout = 5000 module.exports.timeout = 5000
if (!jsEnv.isNode) {
module.exports.fn = null
return
}
const jsdom = require('jsdom')
const { client, xml } = require('@xmpp/client')
const debug = require('@xmpp/debug')
const validator = require('validator')
let xmpp = null, let xmpp = null,
iqCaller = null iqCaller = null