Skip to content
This repository has been archived by the owner on Nov 20, 2024. It is now read-only.

Commit

Permalink
Merge pull request #194 from hermeznetwork/feature/display-coordinato…
Browse files Browse the repository at this point in the history
…r-version-in-coordinator-view

Add call to get /health
  • Loading branch information
mmilenkovic authored Jul 6, 2021
2 parents 8cc809e + e83e915 commit 1431f25
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
11 changes: 10 additions & 1 deletion src/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -355,6 +355,14 @@ async function getConfig (axiosConfig) {
return extractJSON(axios.get(`${baseApiUrl}/${API_VERSION}/config`, axiosConfig))
}

/**
* GET request to the /health endpoint
* @returns {Object} Response data
*/
async function getHealth (axiosConfig) {
return extractJSON(axios.get(`${baseApiUrl}/${API_VERSION}/health`, axiosConfig))
}

export {
PaginationOrder,
_getPageData,
Expand All @@ -379,5 +387,6 @@ export {
postCreateAccountAuthorization,
getCreateAccountAuthorization,
getConfig,
getPoolTransactions
getPoolTransactions,
getHealth
}
8 changes: 8 additions & 0 deletions tests/integration/api.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -334,3 +334,11 @@ test('#_getPageData', () => {
const pageData = CoordinatorAPI._getPageData(32, CoordinatorAPI.PaginationOrder.ASC, 20)
expect(pageData).toEqual({ fromItem: 32, order: CoordinatorAPI.PaginationOrder.ASC, limit: 20 })
})

test('#getHealth', async () => {
CoordinatorAPI.setBaseApiUrl(mockUrlAPI)

const res = await CoordinatorAPI.getHealth()
expect(res).toBeDefined()
expect(res.status).toBe('UP')
})

0 comments on commit 1431f25

Please sign in to comment.