diff --git a/package.json b/package.json index 76710cec..47cd41eb 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "bfx-report", - "version": "4.11.1", + "version": "4.11.2", "description": "Reporting tool", "main": "worker.js", "license": "Apache-2.0", diff --git a/test/1-api.spec.js b/test/1-api.spec.js index 76cc15f9..00ef9516 100644 --- a/test/1-api.spec.js +++ b/test/1-api.spec.js @@ -194,7 +194,7 @@ describe('API', () => { assert.isObject(res.body.error) assert.propertyVal(res.body.error, 'code', 401) assert.propertyVal(res.body.error, 'message', 'Unauthorized') - assert.propertyVal(res.body.error, 'data', null) + assert.isObject(res.body.error.data) assert.propertyVal(res.body, 'id', null) assert.isString(res.body.jsonrpc) }) @@ -1199,10 +1199,11 @@ describe('API', () => { assert.isObject(res.body) assert.isObject(res.body.error) assert.propertyVal(res.body.error, 'code', 400) - assert.isArray(res.body.error.data) - assert.isAbove(res.body.error.data.length, 0) + assert.isObject(res.body.error.data) + assert.isArray(res.body.error.data.errorMetadata) + assert.isAbove(res.body.error.data.errorMetadata.length, 0) - res.body.error.data.forEach((item) => { + res.body.error.data.errorMetadata.forEach((item) => { assert.isObject(item) }) diff --git a/workers/loc.api/helpers/schema.js b/workers/loc.api/helpers/schema.js index 94fd02a9..93ea76a9 100644 --- a/workers/loc.api/helpers/schema.js +++ b/workers/loc.api/helpers/schema.js @@ -56,23 +56,7 @@ const dateFormat = { 'YYYY-MM-DD' ] } -const language = { - type: 'string', - enum: [ - 'en', - 'en-US', - 'ru', - 'zh-CN', - 'zh-TW', - 'tr', - 'tr-TR', - 'es', - 'es-EM', - 'pt', - 'pt-PT', - 'pt-BR' - ] -} +const language = { type: 'string' } const paramsSchemaForPayInvoiceList = { ...paramsSchemaForApi, diff --git a/workers/loc.api/i18next/index.js b/workers/loc.api/i18next/index.js index 5db2016d..a344d24a 100644 --- a/workers/loc.api/i18next/index.js +++ b/workers/loc.api/i18next/index.js @@ -23,9 +23,9 @@ module.exports = (params) => { const configs = merge( { fallbackLng: { - es: ['es-EM'], - pt: ['pt-BR'], - zh: ['zh-CN'], + es: ['es-EM', 'en'], + pt: ['pt-BR', 'en'], + zh: ['zh-CN', 'en'], default: ['en'] }, ns: Object.values(TRANSLATION_NAMESPACES), diff --git a/workers/loc.api/responder/index.js b/workers/loc.api/responder/index.js index af64293a..84c07eab 100644 --- a/workers/loc.api/responder/index.js +++ b/workers/loc.api/responder/index.js @@ -1,5 +1,7 @@ 'use strict' +const { omit } = require('lib-js-util-base') + const AbstractWSEventEmitter = require('../abstract.ws.event.emitter') const { @@ -130,7 +132,6 @@ const _getErrorWithMetadataForNonBaseError = (args, err) => { err.message = err.message.replace(']', `,"${symbol}"]`) err.statusCode = 500 err.statusMessage = `Invalid symbol error, '${symbol}' is not supported` - err.data = [{ symbol }] return err } @@ -163,12 +164,23 @@ const _getErrorMetadata = (args, err, name) => { const message = bfxApiErrorMessage ? `${statusMessage}: BFX API Error${bfxApiStatusText}${bfxApiRawBodyResponse}` : statusMessage - const extendedData = bfxApiErrorMessage - ? { - bfxApiErrorMessage, - ...data - } - : data + const pubRequestParams = ( + args?.params && + typeof args?.params === 'object' + ) + ? omit(args.params, [ + 'id', + 'subAccountApiKeys', + 'subAccountPassword', + 'addingSubUsers', + 'removingSubUsersByEmails' + ]) + : args?.params ?? null + const extendedData = { + pubRequestParams, + bfxApiErrorMessage, + errorMetadata: data + } const error = Object.assign( errWithMetadata,