Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,11 @@
"jsonwebtoken": "^9.0.0",
"moment": "^2.29.4",
"mongodb": "^5.5.0",
"mongoose": "^7.1.1",
"mongoose": "^7.2.1",
"pino": "^8.14.1",
"pino-pretty": "^10.0.0",
"swagger-ui-express": "^4.6.3",
"switcher-client": "^3.1.6",
"switcher-client": "^3.1.7",
"validator": "^13.9.0"
},
"devDependencies": {
Expand All @@ -62,7 +62,7 @@
"jest-sonar-reporter": "^2.0.0",
"node-notifier": "^10.0.1",
"nodemon": "^2.0.22",
"sinon": "^15.0.4",
"sinon": "^15.1.0",
"supertest": "^6.3.3"
},
"repository": {
Expand Down
18 changes: 12 additions & 6 deletions src/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,10 +77,14 @@ app.get('/swagger.json', resourcesAuth(), (_req, res) => {
res.status(200).send(swaggerDocument);
});

app.get('/check', defaultLimiter, (_req, res) => {
res.status(200).send({
status: 'UP',
attributes: {
app.get('/check', defaultLimiter, (req, res) => {
const showDetails = req.query.details === '1';
const response = {
status: 'UP'
};

if (showDetails) {
response.attributes = {
version: swaggerDocument.info.version,
release_time: process.env.RELEASE_TIME,
env: process.env.ENV,
Expand All @@ -96,8 +100,10 @@ app.get('/check', defaultLimiter, (_req, res) => {
max_rpm: process.env.MAX_REQUEST_PER_MINUTE,
regex_max_timeout: process.env.REGEX_MAX_TIMEOUT,
regex_max_blacklist: process.env.REGEX_MAX_BLACLIST
}
});
};
}

res.status(200).send(response);
});

app.get('*', (_req, res) => {
Expand Down
13 changes: 11 additions & 2 deletions tests/admin.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -468,15 +468,24 @@ describe('Testing Admin insertion', () => {
expect(response.body.error).toEqual('Operation not found');
});

test('ADMIN_SUITE - Should get API UP', async () => {
test('ADMIN_SUITE - Should get API UP with details', async () => {
const response = await request(app)
.get('/check')
.get('/check?details=1')
.send().expect(200);

expect(response.body.status).toEqual('UP');
expect(response.body.attributes.version).toEqual(swaggerDocument.info.version);
});

test('ADMIN_SUITE - Should get API UP with NO details', async () => {
const response = await request(app)
.get('/check')
.send().expect(200);

expect(response.body.status).toEqual('UP');
expect(response.body.attributes).toBe(undefined);
});

test('ADMIN_SUITE - Should return OpenAPI Swagger API document', async () => {
const response = await request(app)
.get('/swagger.json')
Expand Down