Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(bungee-hermes): ability to use connectors without instanciating …
…APIs Signed-off-by: Carlos Amaro <[email protected]> refactor(bungee): besu strategy error handling and input validation Notice a few things: 1. The http-errors-enhanced-cjs library is being used to encode information about whether an error is consdiered (by us) as a user error or a bug in our code (e.g. it signals who do we think are at fault which is the important question when handling errors.). If we think the input was valid an we should hae succeeded with the function execution, then we throw an InternalServerError. Otherwise if we think the input was not in the required format, we throw a BadRequestError notifying the user (or developer who is calling our function) that they need to fix their input that they provided us with. 2. The error handling code and the output validation code are flattened out as much as possible so that it's easier to read and understand what the code does in what scenario and as the execution progresses the possible bad situations are slowly but surely eliminated and by the end we are confident that the output was in the expected format and that we can return it as-is and we don't need to have any type casting at all. 3. I also added the `pluginRegistry` parameter to the bungee plugin's options because this is an object that the API server passes in to every plugin that it instanties which is meant to facilitate the cross-plugin interaction, e.g. you can use in each plugin the passed in pluginRegistry to look up other plugins instances directly and invoke them without needing an API client object for doing so (which also adds a huge overhead of network latency) The relevant piece of code to be aware of to see why this is working is in the API server class, as pasted below where you can see that the pluginRegistry gets appended to all the plugin options regardless of which kind of plugin it is: ```typescript private async instantiatePlugin( pluginImport: PluginImport, registry: PluginRegistry, ): Promise<ICactusPlugin> { const fnTag = `${this.className}#instantiatePlugin`; const { logLevel } = this.options.config; const { packageName, options } = pluginImport; this.log.info(`Creating plugin from package: ${packageName}`, options); const pluginOptions = { ...options, logLevel, pluginRegistry: registry }; ``` Signed-off-by: Peter Somogyvari <[email protected]> refactor(bungee): besu, ethereum and fabric strategy error handling and input validation Signed-off-by: Carlos Amaro <[email protected]>
- Loading branch information