Skip to content

Commit

Permalink
Maintenance fixes (#42)
Browse files Browse the repository at this point in the history
* Update README.md

* Patch reviews and CI/CD Updates (#41)

* Trim date and remove url

* Serve openapi.json

* Update Actions

* Cashless Consumer updated GooglePlayAPI.postman_collection

* Sync versions

* Update docker base image to node 18
  • Loading branch information
srikanthlogic committed Sep 22, 2023
1 parent 9dc0b28 commit 2c7e784
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 16 deletions.
2 changes: 1 addition & 1 deletion .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@ fly.staging.toml
.eslintrc
newman
Spacefile
assets
Discovery.md
6 changes: 3 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
# Use the official Node.js image as base
FROM node:16-alpine
FROM node:18-alpine

# Set metadata labels
LABEL maintainer="Srikanth <[email protected]>" \
version="1.0" \
version="1.5.0" \
description="Docker image for running Google Play API"

# Create and set the working directory
Expand All @@ -12,7 +12,7 @@ WORKDIR /home/node/app
# Copy only the package.json and package-lock.json first to leverage Docker caching
COPY package*.json ./

RUN npm install -g npm@9.8.1
RUN npm install -g npm@10.1.0

# Install dependencies
RUN npm ci --quiet --omit=dev
Expand Down
11 changes: 4 additions & 7 deletions lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -127,24 +127,23 @@ router.get('/apps/:appId/reviews', function (req, res, next) {
const opts = Object.assign({ appId: req.params.appId }, req.query);
const includeUserData = req.query.userdata === 'true';
const includeReplies = req.query.replies == 'true'

const processReviews = (reviews, includeUserData, includeReplies) => {
const sanitizeReplyText = (text, userName) => {
const userNameParts = userName.split(' ');

function escapeRegExp(string) {
return string.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
}

const userNamePatterns = userNameParts.map(part => new RegExp(escapeRegExp(part), 'gi'));

return userNamePatterns.reduce(
(sanitizedText, pattern) => sanitizedText.replace(pattern, '[REDACTED_USER]'),
text
);
};


if (!includeUserData) {
reviews.data = reviews.data.map(review => {
const { userName, userImage, replyText, url, ...rest } = review;
Expand All @@ -166,8 +165,7 @@ router.get('/apps/:appId/reviews', function (req, res, next) {
return rest;
});
}
else
{
else {
reviews.data = reviews.data.map(review => {
const { url, ...rest } = review;
rest.date = rest.date.split('T')[0];
Expand All @@ -177,7 +175,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) {
Expand Down
4 changes: 2 additions & 2 deletions openapi/options.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@
"url": "https://en.wikipedia.org/wiki/MIT_License"
},
"title": "Google Play Metadata API",
"version": "0.3.6",
"version": "1.5.0",
"xLogo": {
"altText": "CashlessConsumer logo",
"altText": "Google Play API logo",
"backgroundColor": "#FFFFFF",
"url": "./assets/icon.png"
}
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "google-play-api",
"version": "1.4.0",
"version": "1.5.0",
"description": "turn google play scraper into a RESTful API",
"main": "server.js",
"type": "module",
Expand Down
4 changes: 2 additions & 2 deletions test.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@ import environmentData from './PostmanCollections/postman_environment.json' asse

const runTests = async () => {
try {
await newman.run({
newman.run({
collection: collectionData,
environment: environmentData,
reporters: ['cli', 'htmlextra']
});

await newman.run({
newman.run({
collection: utCollectionData,
environment: environmentData,
reporters: ['cli', 'htmlextra']
Expand Down

0 comments on commit 2c7e784

Please sign in to comment.