Skip to content

Commit

Permalink
Patch reviews and CI/CD Updates (#41)
Browse files Browse the repository at this point in the history
* Trim datee and remove url

* Serve openapi.json

* Update Actions
  • Loading branch information
srikanthlogic committed Sep 22, 2023
1 parent 45add13 commit bfc548b
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 7 deletions.
4 changes: 3 additions & 1 deletion .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
name: CI/CD Pipeline
name: Deploy Pipeline

on:
workflow_dispatch:
push:
branches: ["main", "dev"]
paths: ["!PostmanCollections/**", "!./github/**"]
pull_request:
branches: [ "dev" ]

jobs:
build_and_test:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/newman.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ on:
branches: [ "main" ]
paths: [ '!PostmanCollections/**' , '!./github/**' ]
pull_request:
branches: [ "main" ]
branches: [ "main", "dev" ]

jobs:
newman:
Expand Down
19 changes: 15 additions & 4 deletions lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -143,12 +143,15 @@ router.get('/apps/:appId/reviews', function (req, res, next) {
text
);
};


if (!includeUserData) {
reviews.data = reviews.data.map(review => {
const { userName, userImage, replyText, ...rest } = review;
const { userName, userImage, replyText, url, ...rest } = review;
rest.date = rest.date.split('T')[0];
if (!includeReplies) {
delete rest.replyText;
delete rest.replyDate;
} else if (includeReplies && replyText) {
const sanitizedReplyText = sanitizeReplyText(replyText, userName);
rest.replyText = sanitizedReplyText;
Expand All @@ -158,15 +161,23 @@ router.get('/apps/:appId/reviews', function (req, res, next) {
} else {
if (!includeReplies) {
reviews.data = reviews.data.map(review => {
const { replyText, ...rest } = review;
return replyText !== null ? rest : review;
const { replyText, replyDate, url, ...rest } = review;
rest.date = rest.date.split('T')[0];
return rest;
});
}
else
{
reviews.data = reviews.data.map(review => {
const { url, ...rest } = review;
rest.date = rest.date.split('T')[0];
return rest;
});
}
}
return reviews;
};



// Check if nextPaginationToken is present and not null
if (req.query.nextPaginationToken !== null) {
Expand Down
3 changes: 2 additions & 1 deletion server.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,15 @@ import router from './lib/index.js';
import swaggerDocument from './openapi/swagger.json' assert { type: "json" };
import swaggerUi from 'swagger-ui-express';


const app = Express();
const port = process.env.PORT || 3000;

var options = {
customCss: '.swagger-ui .topbar { display: none }'
};

app.use('/openapi.json', Express.static('openapi/swagger.json'));

app.use('/api-docs', swaggerUi.serve, swaggerUi.setup(swaggerDocument, options));
app.use('/api/', router);

Expand Down

0 comments on commit bfc548b

Please sign in to comment.