Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
exports.startReview = function (config, first_run) {
var appInformation = {};
//scrape Google Play for app information first
playScraper.app({appId: config.appId})
.then(function (appData, error) {
if (error) {
return console.error("ERROR: [" + config.appId + "] Could not scrape Google Play, " + error);
}
appInformation.appName = appData.title;
appInformation.appIcon = appData.icon;
exports.fetchGooglePlayReviews(config, appInformation, function (reviews) {
// If we don't have any published reviews, then treat this as a baseline fetch, we won't post any
// reviews to slack, but new ones from now will be posted
if (first_run) {
var reviewLength = reviews.length;
for (var i = 0; i < reviewLength; i++) {
var initialReview = reviews[i];
itunes.app({
appId: opt.appId,
country: opt.country, // TODO: Support more countries
})
.then((data) => {
setMetrics(store, opt.country, data) // TODO: Support more countries
.then(resolve)
.catch(reject);
})
.catch((err) => {
reject(new Error(`Itunes Scraper error for the app "${opt.appId}" (${opt.country}): ${err.message}`));
});
}
if (store === 'gplay') {
gplay.app({
appId: opt.appId,
country: opt.country, // TODO: Support more countries
})
.then((data) => {
setMetrics(store, opt.country, data) // TODO: Support more countries
.then(resolve)
.catch(reject);
})
.catch((err) => {
reject(new Error(`Google Play Scraper error for the app "${opt.appId}"" (${opt.country}): ${err.message}`));
});
}
});
}
router.get('/apps/:appId', function (req, res, next) {
const opts = Object.assign({appId: req.params.appId}, req.query);
gplay.app(opts)
.then(cleanUrls(req))
.then(res.json.bind(res))
.catch(next);
});