2017-09-07 14:17:24 +03:00
|
|
|
var got = require('got'),
|
2017-12-12 00:47:46 +03:00
|
|
|
_ = require('lodash'),
|
2017-09-07 14:17:24 +03:00
|
|
|
validator = require('../data/validation').validator,
|
2017-12-14 00:28:43 +03:00
|
|
|
common = require('./common');
|
2017-09-07 14:17:24 +03:00
|
|
|
|
|
|
|
module.exports = function request(url, options) {
|
|
|
|
if (_.isEmpty(url) || !validator.isURL(url)) {
|
2017-12-12 00:47:46 +03:00
|
|
|
return Promise.reject(new common.errors.InternalServerError({
|
2017-09-07 14:17:24 +03:00
|
|
|
message: 'URL empty or invalid.',
|
|
|
|
code: 'URL_MISSING_INVALID',
|
|
|
|
context: url
|
|
|
|
}));
|
|
|
|
}
|
|
|
|
|
2018-01-02 14:18:56 +03:00
|
|
|
return got(url, options);
|
2017-09-07 14:17:24 +03:00
|
|
|
};
|