diff --git a/lib/index.js b/lib/index.js index c334bc8..1ef7a7a 100644 --- a/lib/index.js +++ b/lib/index.js @@ -10,7 +10,6 @@ const router = Express.Router(); const toList = (apps) => ({ results: apps }); router.use((req, res, next) => { - if (!req.query.country) { req.query.country = process.env.COUNTRY_OF_QUERY || 'US'; } @@ -137,7 +136,8 @@ router.get('/apps/:appId/permissions', function (req, res, next) { /* App reviews */ router.get('/apps/:appId/reviews', function (req, res, next) { - const opts = Object.assign({ appId: req.params.appId, country: req.query.country }, req.query); + const opts = Object.assign({ appId: req.params.appId, country: req.query.country, num: parseInt(req.query.num) || 100 }, req.query); + const includeUserData = req.query.userdata === 'true'; const includeReplies = req.query.replies === 'true'; @@ -177,8 +177,7 @@ router.get('/apps/:appId/reviews', function (req, res, next) { rest.date = rest.date.split('T')[0]; return rest; }); - } - else { + } else { reviews.data = reviews.data.map(review => { const { url, ...rest } = review; rest.date = rest.date.split('T')[0]; @@ -189,12 +188,6 @@ router.get('/apps/:appId/reviews', function (req, res, next) { return reviews; }; - // Check if nextPaginationToken is present and not null - if (req.query.nextPaginationToken !== null) { - opts.paginate = true; - opts.nextPaginationToken = req.query.nextPaginationToken; - } - // Sort criteria - Helpful, Most rated, and Newest reviews // https://github.com/facundoolano/google-play-scraper/blob/89202849f6054f6ac64790a385abc3c18ae98df1/lib/constants.js#L69C7-L69C7 opts.sort = req.query.sort === 'helpful' ? 1 : req.query.sort === 'rated' ? 3 : 2; diff --git a/package-lock.json b/package-lock.json index 7326e42..a2372a8 100644 --- a/package-lock.json +++ b/package-lock.json @@ -10,7 +10,7 @@ "license": "ISC", "dependencies": { "express": "^4.19.2", - "google-play-scraper": "^10.0.0", + "google-play-scraper": "https://github.com/srikanthlogic/google-play-scraper.git#c0bdceca9288165f9af625363c621b901f506390", "morgan": "^1.10.0", "postman-to-openapi": "^3.0.1", "swagger-ui-express": "^5.0.0" @@ -3485,14 +3485,14 @@ }, "node_modules/google-play-scraper": { "version": "10.0.0", - "resolved": "https://registry.npmjs.org/google-play-scraper/-/google-play-scraper-10.0.0.tgz", - "integrity": "sha512-iRVV6HlMYOToPNTA8pub/t8rmr9zhyuaomWIkK1Nck7hwcy8+OX5u7RB7fkf6YtOfBfIlFZ04Yf28Y67vXgNkQ==", + "resolved": "git+ssh://git@github.com/srikanthlogic/google-play-scraper.git#c0bdceca9288165f9af625363c621b901f506390", "dependencies": { "cheerio": "^1.0.0-rc.12", "debug": "^3.1.0", "got": "^11.8.6", "memoizee": "^0.4.14", - "ramda": "^0.29.0" + "ramda": "^0.29.0", + "tough-cookie": "^4.1.3" } }, "node_modules/google-play-scraper/node_modules/debug": { @@ -6711,8 +6711,7 @@ "node_modules/psl": { "version": "1.9.0", "resolved": "https://registry.npmjs.org/psl/-/psl-1.9.0.tgz", - "integrity": "sha512-E/ZsdU4HLs/68gYzgGTkMicWTLPdAftJLfJFlLUAAKZGkStNU72sZjT66SnMDVOfOWY/YAoiD7Jxa9iHvngcag==", - "dev": true + "integrity": "sha512-E/ZsdU4HLs/68gYzgGTkMicWTLPdAftJLfJFlLUAAKZGkStNU72sZjT66SnMDVOfOWY/YAoiD7Jxa9iHvngcag==" }, "node_modules/pump": { "version": "3.0.0", @@ -6727,7 +6726,6 @@ "version": "2.3.0", "resolved": "https://registry.npmjs.org/punycode/-/punycode-2.3.0.tgz", "integrity": "sha512-rRV+zQD8tVFys26lAGR9WUuS4iUAngJScM+ZRSKtvl5tKeZ2t5bvdNFdNHBW9FWR4guGHlgmsZ1G7BSm2wTbuA==", - "dev": true, "engines": { "node": ">=6" } @@ -6764,8 +6762,7 @@ "node_modules/querystringify": { "version": "2.2.0", "resolved": "https://registry.npmjs.org/querystringify/-/querystringify-2.2.0.tgz", - "integrity": "sha512-FIqgj2EUvTa7R50u0rGsyTftzjYmv/a3hO345bZNrqabNqjtgiDMgmo4mkUjd+nzU5oF3dClKqFIPUKybUyqoQ==", - "dev": true + "integrity": "sha512-FIqgj2EUvTa7R50u0rGsyTftzjYmv/a3hO345bZNrqabNqjtgiDMgmo4mkUjd+nzU5oF3dClKqFIPUKybUyqoQ==" }, "node_modules/queue-microtask": { "version": "1.2.3", @@ -7078,8 +7075,7 @@ "node_modules/requires-port": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/requires-port/-/requires-port-1.0.0.tgz", - "integrity": "sha512-KigOCHcocU3XODJxsu8i/j8T9tzT4adHiecwORRQ0ZZFcp7ahwXuRU1m+yuO90C5ZUyGeGfocHDI14M3L3yDAQ==", - "dev": true + "integrity": "sha512-KigOCHcocU3XODJxsu8i/j8T9tzT4adHiecwORRQ0ZZFcp7ahwXuRU1m+yuO90C5ZUyGeGfocHDI14M3L3yDAQ==" }, "node_modules/resolve": { "version": "1.22.8", @@ -7911,6 +7907,20 @@ "node": ">=0.6" } }, + "node_modules/tough-cookie": { + "version": "4.1.3", + "resolved": "https://registry.npmjs.org/tough-cookie/-/tough-cookie-4.1.3.tgz", + "integrity": "sha512-aX/y5pVRkfRnfmuX+OdbSdXvPe6ieKX/G2s7e98f4poJHnqH3281gDPm/metm6E/WRamfx7WC4HUqkWHfQHprw==", + "dependencies": { + "psl": "^1.1.33", + "punycode": "^2.1.1", + "universalify": "^0.2.0", + "url-parse": "^1.5.3" + }, + "engines": { + "node": ">=6" + } + }, "node_modules/tsconfig-paths": { "version": "3.15.0", "resolved": "https://registry.npmjs.org/tsconfig-paths/-/tsconfig-paths-3.15.0.tgz", @@ -8159,7 +8169,6 @@ "version": "0.2.0", "resolved": "https://registry.npmjs.org/universalify/-/universalify-0.2.0.tgz", "integrity": "sha512-CJ1QgKmNg3CwvAv/kOFmtnEN05f0D/cn9QntgNOQlQF9dgvVTHj3t+8JPdjqawCHk7V/KA+fbUqzZ9XWhcqPUg==", - "dev": true, "engines": { "node": ">= 4.0.0" } @@ -8249,7 +8258,6 @@ "version": "1.5.10", "resolved": "https://registry.npmjs.org/url-parse/-/url-parse-1.5.10.tgz", "integrity": "sha512-WypcfiRhfeUP9vvF0j6rw0J3hrWrw6iZv3+22h6iRMJ/8z1Tj6XfLP4DsUix5MhMPnXpiHDoKyoZ/bdCkwBCiQ==", - "dev": true, "dependencies": { "querystringify": "^2.1.1", "requires-port": "^1.0.0" diff --git a/package.json b/package.json index 5da5460..1a53d0e 100644 --- a/package.json +++ b/package.json @@ -17,7 +17,7 @@ }, "dependencies": { "express": "^4.19.2", - "google-play-scraper": "^10.0.0", + "google-play-scraper": "https://github.com/srikanthlogic/google-play-scraper.git#c0bdceca9288165f9af625363c621b901f506390", "morgan": "^1.10.0", "postman-to-openapi": "^3.0.1", "swagger-ui-express": "^5.0.0"