Skip to content

Commit

Permalink
feat: added missing types and maintenance fixes (#428)
Browse files Browse the repository at this point in the history
* feat: added missing types and maintenance fixes

* feat: added missing types and maintenance fixes
  • Loading branch information
shashi165 authored Jan 24, 2025
1 parent f25dd6d commit f8e84e5
Show file tree
Hide file tree
Showing 10 changed files with 2,448 additions and 2,969 deletions.
2 changes: 1 addition & 1 deletion .nvmrc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
18.17.1
18.20.4
2 changes: 1 addition & 1 deletion CODEOWNERS
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
## @global-owner1 and @global-owner2 will be requested for
## review when someone opens a pull request.
#* @global-owner1 @global-owner2
* @mdebarros @elnyry-sam-k @vijayg10 @kleyow @oderayi
* @bushjames @elnyry-sam-k @vijayg10 @kleyow @oderayi @shashi165 @gibaros

## Order is important; the last matching pattern takes the most
## precedence. When someone opens a pull request that only
Expand Down
5,364 changes: 2,404 additions & 2,960 deletions package-lock.json

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,9 @@
"@hapi/catbox": "12.1.1",
"@hapi/catbox-memory": "5.0.1",
"@hapi/hapi": "21.3.12",
"@hapi/joi": "17.1.1",
"@hapi/joi-date": "2.0.1",
"@mojaloop/inter-scheme-proxy-cache-lib": "2.3.1",
"@mojaloop/sdk-standard-components": "19.6.3",
"axios": "1.7.9",
"clone": "2.1.2",
"dotenv": "16.4.7",
Expand All @@ -72,6 +72,7 @@
"fast-safe-stringify": "^2.1.1",
"immutable": "5.0.3",
"ioredis": "^5.4.2",
"joi": "17.13.3",
"lodash": "4.17.21",
"mustache": "4.2.0",
"openapi-backend": "5.11.1",
Expand Down
36 changes: 35 additions & 1 deletion src/index.d.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { Utils as HapiUtil, Server } from '@hapi/hapi'
import { Joi } from 'joi'
import { ILogger } from '@mojaloop/central-services-logger/src/contextLogger'

declare namespace CentralServicesShared {
Expand Down Expand Up @@ -663,6 +664,9 @@ declare namespace CentralServicesShared {
type ProtocolResources = string[]
type ProtocolVersions = (string | symbol)[]
type ApiTypeValues = 'fspiop' | 'iso20022'
type APIDocumentationPluginOptions =
| { documentPath: string; document?: never }
| { document?: string; documentPath?: never }

type LoggingPluginOptions = {
log?: ILogger,
Expand Down Expand Up @@ -694,10 +698,40 @@ declare namespace CentralServicesShared {
defaultProtocolResources: ProtocolResources
defaultProtocolVersions: ProtocolVersions
};
OpenapiBackendValidator: {
plugin: {
name: string,
register: (server: Server) => void
}
};
HapiEventPlugin: {
plugin: {
name: string,
register: (server: Server) => void
}
};
customCurrencyCodeValidation: (joi: Joi) => {
base: Joi.StringSchema;
type: string;
messages: {
'currency.base': string;
};
rules: {
currency: {
validate: (value: string, helpers: any) => string | any;
};
};
};
APIDocumentation: {
plugin: {
name: string,
register: (server: Server, options: APIDocumentationPluginOptions) => void
}
};
loggingPlugin: {
name: string,
register: (server: Server, options?: LoggingPluginOptions) => Promise<void>
}
};
API_TYPES: Record<ApiTypeValues, ApiTypeValues>;
}
// todo: define the rest of the types
Expand Down
2 changes: 1 addition & 1 deletion src/util/hapi/plugins/apiDocumentation.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ const APIDocBuilder = require('../../documentation').APIDocBuilder

/**
* Hapi plugin to add '/swagger.json' and '/documentation' endpoints.
* It generates API documenation from supplied OpenAPI spec (json or yaml).
* It generates API documentation from supplied OpenAPI spec (json or yaml).
*
* options.documentPath - Full path to the OpenAPI (fka Swagger) document (JSON or YAML). Mutually exclusive to `document` option.
* options.document - OpenAPI document as string. Mutually exclusive to `documentPath` option.
Expand Down
2 changes: 1 addition & 1 deletion src/util/hapi/plugins/headerValidation.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
// accuracy of this statement has not been thoroughly tested.

const { Factory: { createFSPIOPError }, Enums } = require('@mojaloop/central-services-error-handling')
const RootJoi = require('@hapi/joi')
const RootJoi = require('joi')
const DateExtension = require('@hapi/joi-date')
const Joi = RootJoi.extend(DateExtension)
const { API_TYPES, MAX_CONTENT_LENGTH } = require('../../../constants')
Expand Down
2 changes: 1 addition & 1 deletion test/unit/healthCheck/HealthCheck.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@

const Test = require('tapes')(require('tape'))
const Sinon = require('sinon')
const Joi = require('@hapi/joi')
const Joi = require('joi')

const HealthCheck = require('../../../src/healthCheck').HealthCheck

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
******/

const Test = require('tape')
const BaseJoi = require('@hapi/joi')
const BaseJoi = require('joi')
const currencyExtension = require('../../../../../src/util/hapi/plugins/customCurrencyCodeExtension')
const Joi = BaseJoi.extend(currencyExtension)

Expand Down
2 changes: 1 addition & 1 deletion test/unit/util/hapi/plugins/rawPayloadToDataUri.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
const Hapi = require('@hapi/hapi')
const Test = require('tapes')(require('tape'))
const Sinon = require('sinon')
const Joi = require('@hapi/joi')
const Joi = require('joi')
const StreamingProtocol = require('../../../../../src/util').StreamingProtocol

const init = async (options) => {
Expand Down

0 comments on commit f8e84e5

Please sign in to comment.