Typically my use case :
Is it the good way to do it ?
Hi there! I'm trying to catch some specific errors in the setErrorHandler
and return a valid response instead of an error - my plan is to catch joi validation errors there and return a non-error response. I believe setErrorHandler
doesn't have the ability to convert the response to a non-error, am I right?
Also, I believe the docs are wrong, because in the code setErrorHandler
accepts 3 arguments (hemera, error, reply)
but in the docs only one is mentioned (error)
.
This is my code:
hemera.setErrorHandler((hemera, error) => {
return new Promise((resolve, reject) => {
if (error.isJoi && error.name === 'ValidationError') {
resolve({ error: true, message: {error: error.message }, status: 422 });
} else {
reject(error);
}
});
});
yarn install
. Are there plans to update the following dependencies?yarn
:warning hemera-joi > joi@12.0.0: This version has been deprecated in accordance with the hapi support policy (hapi.im/support). Please upgrade to the latest version to get the best features, bug fixes, and security patches. If you are unable to upgrade at this time, paid support is available for older versions (hapi.im/commercial).
warning hemera-joi > joi > topo@2.0.2: This version has been deprecated in accordance with the hapi support policy (hapi.im/support). Please upgrade to the latest version to get the best features, bug fixes, and security patches. If you are unable to upgrade at this time, paid support is available for older versions (hapi.im/commercial).
warning hemera-joi > joi > hoek@4.2.1: This version has been deprecated in accordance with the hapi support policy (hapi.im/support). Please upgrade to the latest version to get the best features, bug fixes, and security patches. If you are unable to upgrade at this time, paid support is available for older versions (hapi.im/commercial).
warning hemera-joi > joi > topo > hoek@4.2.1: This version has been deprecated in accordance with the hapi support policy (hapi.im/support). Please upgrade to the latest version to get the best features, bug fixes, and security patches. If you are unable to upgrade at this time, paid support is available for older versions (hapi.im/commercial).
warning nats-hemera > joi@11.1.1: This version has been deprecated in accordance with the hapi support policy (hapi.im/support). Please upgrade to the latest version to get the best features, bug fixes, and security patches. If you are unable to upgrade at this time, paid support is available for older versions (hapi.im/commercial).
warning nats-hemera > joi > hoek@4.2.1: This version has been deprecated in accordance with the hapi support policy (hapi.im/support). Please upgrade to the latest version to get the best features, bug fixes, and security patches. If you are unable to upgrade at this time, paid support is available for older versions (hapi.im/commercial).
warning nats-hemera > joi > topo@2.0.2: This version has been deprecated in accordance with the hapi support policy (hapi.im/support). Please upgrade to the latest version to get the best features, bug fixes, and security patches. If you are unable to upgrade at this time, paid support is available for older versions (hapi.im/commercial).
warning nats-hemera > heavy@4.0.4: This version has been deprecated in accordance with the hapi support policy (hapi.im/support). Please upgrade to the latest version to get the best features, bug fixes, and security patches. If you are unable to upgrade at this time, paid support is available for older versions (hapi.im/commercial).
warning nats-hemera > heavy > hoek@4.2.1: This version has been deprecated in accordance with the hapi support policy (hapi.im/support). Please upgrade to the latest version to get the best features, bug fixes, and security patches. If you are unable to upgrade at this time, paid support is available for older versions (hapi.im/commercial).
warning nats-hemera > heavy > joi@10.6.0: This version has been deprecated in accordance with the hapi support policy (hapi.im/support). Please upgrade to the latest version to get the best features, bug fixes, and security patches. If you are unable to upgrade at this time, paid support is available for older versions (hapi.im/commercial).
warning nats-hemera > heavy > joi > hoek@4.2.1: This version has been deprecated in accordance with the hapi support policy (hapi.im/support). Please upgrade to the latest version to get the best features, bug fixes, and security patches. If you are unable to upgrade at this time, paid support is available for older versions (hapi.im/commercial).
Continued, since it wouldn't let me paste everything in one post:
warning nats-hemera > heavy > joi > topo@2.0.2: This version has been deprecated in accordance with the hapi support policy (hapi.im/support). Please upgrade to the latest version to get the best features, bug fixes, and security patches. If you are unable to upgrade at this time, paid support is available for older versions (hapi.im/commercial).
warning nats-hemera > heavy > boom@5.2.0: This version has been deprecated in accordance with the hapi support policy (hapi.im/support). Please upgrade to the latest version to get the best features, bug fixes, and security patches. If you are unable to upgrade at this time, paid support is available for older versions (hapi.im/commercial).
warning nats-hemera > heavy > boom > hoek@4.2.1: This version has been deprecated in accordance with the hapi support policy (hapi.im/support). Please upgrade to the latest version to get the best features, bug fixes, and security patches. If you are unable to upgrade at this time, paid support is available for older versions (hapi.im/commercial).
warning nats-hemera > heavy > joi > items@2.1.2: This module has been deprecated in accordance with the hapi support policy (hapi.im/support). Please upgrade to the latest version of hapi to get the best features, bug fixes, and security patches. If you are unable to upgrade at this time, paid support is available for older versions (hapi.im/commercial).
Also, I get this warning, too:
warning " > nats-hemera@7.0.1" has incorrect peer dependency "nats@>= 0.8.x <= 1.2.x".
However, my project does seem to work fine with NATS server version 2.0.4.
import Hemera from 'nats-hemera';
import hemeraAjv from 'hemera-ajv';
import * as NATS from './dependencies/nats';
// RPC dependencies
export const nats = NATS.connection;
const hemera = new Hemera(nats, { logLevel: HEMERA_LOG_LEVEL || 'info' });
hemera.use(hemeraAjv);
hemera.addSchema({
$id: 'getQuoteRequestSchema',
type: 'object',
required: [
'source_currency',
'destination_currency',
'source_amount'
],
properties: {
source_currency: { type: 'string', maxLength: 3 },
destination_currency: { type: 'string', maxLength: 3 },
source_amount: { type: ['string', 'number'] }
},
additionalProperties: false
});
TypeError: hemera.addSchema is not a function