Skip to content

Commit

Permalink
chore: use the central-services-metrics plugin (#110)
Browse files Browse the repository at this point in the history
  • Loading branch information
kalinkrustev authored Nov 25, 2024
1 parent 372d1b1 commit 8d75eb3
Show file tree
Hide file tree
Showing 9 changed files with 212 additions and 375 deletions.
3 changes: 2 additions & 1 deletion audit-ci.jsonc
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
"GHSA-p9pc-299p-vxgp",
"GHSA-h755-8qp9-cq85",
"GHSA-f9xv-q969-pqx4",
"GHSA-7fh5-64p2-3v2j"
"GHSA-7fh5-64p2-3v2j",
"GHSA-3xgq-45jj-v275" // https://github.com/advisories/GHSA-3xgq-45jj-v275
]
}
454 changes: 194 additions & 260 deletions package-lock.json

Large diffs are not rendered by default.

16 changes: 8 additions & 8 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -61,14 +61,14 @@
"dependencies": {
"@hapi/boom": "10.0.1",
"@hapi/good": "9.0.1",
"@hapi/hapi": "21.3.10",
"@hapi/hapi": "21.3.12",
"@hapi/inert": "7.1.0",
"@hapi/vision": "7.0.3",
"@mojaloop/central-services-error-handling": "13.0.1",
"@mojaloop/central-services-error-handling": "13.0.2",
"@mojaloop/central-services-health": "15.0.0",
"@mojaloop/central-services-logger": "11.5.1",
"@mojaloop/central-services-metrics": "12.0.8",
"@mojaloop/central-services-shared": "18.9.0",
"@mojaloop/central-services-metrics": "12.2.1",
"@mojaloop/central-services-shared": "18.11.2",
"@mojaloop/event-sdk": "14.1.1",
"ajv": "8.17.1",
"ajv-keywords": "5.1.0",
Expand Down Expand Up @@ -98,16 +98,16 @@
"jsonpointer": "5.0.0"
},
"devDependencies": {
"@mojaloop/ml-testing-toolkit-shared-lib": "14.0.1",
"@types/jest": "29.5.13",
"@mojaloop/ml-testing-toolkit-shared-lib": "14.0.2",
"@types/jest": "29.5.14",
"audit-ci": "^7.1.0",
"get-port": "5.1.1",
"jest": "29.7.0",
"jest-junit": "16.0.0",
"jsdoc": "4.0.3",
"jsdoc": "4.0.4",
"license-checker": "25.0.1",
"npm-audit-resolver": "3.0.0-RC.0",
"npm-check-updates": "17.1.3",
"npm-check-updates": "17.1.11",
"pre-commit": "1.2.2",
"replace": "^1.2.2",
"sinon": "19.0.2",
Expand Down
2 changes: 0 additions & 2 deletions src/handlers/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,11 @@ const transactionRequests = require('./transactionRequests')
const transactionRequestsId = require('./transactionRequests/{ID}')
const transactionRequestsErrorByID = require('./transactionRequests/{ID}/error')
const health = require('./health')
const metrics = require('./metrics')
const authorizationsId = require('./authorizations/{ID}')
const authorizationsIdError = require('./authorizations/{ID}/error')

module.exports = {
HealthGet: health.get,
MetricsGet: metrics.get,
TransactionRequestsErrorByID: transactionRequestsErrorByID.put,
TransactionRequestsByID: transactionRequestsId.get,
TransactionRequestsByIDPut: transactionRequestsId.put,
Expand Down
43 changes: 0 additions & 43 deletions src/handlers/metrics.js

This file was deleted.

9 changes: 0 additions & 9 deletions src/handlers/routes.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,15 +56,6 @@ const APIRoutes = (api) => [
description: 'GET health'
}
},
{
method: 'GET',
path: '/metrics',
handler: (req, h) => handleRequest(api, req, h),
config: {
tags: ['api', 'metrics'],
description: 'GET service metrics'
}
},
{
method: 'PUT',
path: '/transactionRequests/{ID}/error',
Expand Down
3 changes: 2 additions & 1 deletion src/plugins.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ const ErrorHandling = require('@mojaloop/central-services-error-handling')
const FSPIOPHeaderValidationPlugin = require('@mojaloop/central-services-shared').Util.Hapi.FSPIOPHeaderValidation
const EventPlugin = require('@mojaloop/central-services-shared').Util.Hapi.HapiEventPlugin
const OpenapiBackendValidator = require('@mojaloop/central-services-shared').Util.Hapi.OpenapiBackendValidator
const MetricsPlugin = require('@mojaloop/central-services-metrics').plugin

const registerPlugins = async (server, openAPIBackend) => {
await server.register(OpenapiBackendValidator)
Expand Down Expand Up @@ -102,7 +103,7 @@ const registerPlugins = async (server, openAPIBackend) => {
options: getOptionsForFSPIOPHeaderValidation()
})

await server.register([Inert, Vision, Blipp, ErrorHandling, EventPlugin])
await server.register([Inert, Vision, Blipp, ErrorHandling, EventPlugin, MetricsPlugin])
}

module.exports = {
Expand Down
7 changes: 6 additions & 1 deletion test/unit/handlers/health.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,12 @@ let sandbox

let server
jest.mock('@mojaloop/central-services-metrics', () => ({
setup: jest.fn()
setup: jest.fn(),
plugin: {
name: 'metrics',
version: '1.0.0',
register: jest.fn()
}
}))

/**
Expand Down
50 changes: 0 additions & 50 deletions test/unit/handlers/metrics.test.js

This file was deleted.

0 comments on commit 8d75eb3

Please sign in to comment.