[Steem-red] - Globals Nodes, Error Handling, Input Validation, and Required Fields

in #utopian-io8 years ago (edited)

Screen Shot 2018-01-28 at 5.28.29 AM.png

Errors fixed


Errors were not handled in a correct way in the library. For instance, when a user leave one of the required fields empty, the library didn't return any results. To fix this issue, I wrote the required fields validations by using a generic function to avoid repetition of code. Basically, I just checked for empty strings and null fields in the required inputs. In addition, I added the required attribute to the properties in Node-RED templates. So, by having the correct validations, Node-RED will tell the user that required fields are missing when they save the node or deploy the flow.

To return any error from the API as a payload to Node-RED, I created a if and else condition to determine whether it returned a response or an error. To be able to do so, I also had to create initial status of the node and final status at the error to handle any stage of the data.

Featured Added


New nodes were added covering the following methods from the SteemJs API:

  • getChainProperties
  • getConfig
  • getCurrentMedianHistoryPrice
  • getDynamicGlobalProperties
  • getFeedHistory
  • getHardforkVersion
  • getNextScheduledHardfork
  • getRewardFund
  • getVestingDelegations

All these nodes belong to the Globals category in the library and they all have a short description of what it does.

Requirements

To run the nodes on your localhost you must have Node-RED installed on your localhost. To install Node-RED, run the following command in your terminal:

$ sudo npm install -g --unsafe-perm node-red

Installation

$ git clone https://github.com/jayserdny/node-red-contrib-steem
$ cd node-red-contrib-steem
$ npm install

To install the node modules on your localhost, install it into your Node-RED runtime.

$ sudo npm link
$ cd ~/.node-red
$ npm link node-red-contrib-steem

Run node-red.

$ node-red

Open a browser and go to the address http://127.0.0.1:1880.

Roadmap


As a roadmap, I will keep adding the missing nodes until have 100% coverage of the SteemJs API.

Contributions


To contribute fork the node-red-contrib-steem repository and submit pull requests.

Changelog


0.0.3 - 2018-01-28
  • Added getChainProperties, getConfig, getCurrentMedianHistoryPrice, getDynamicGlobalProperties, getFeedHistory, getHardforkVersion, getNextScheduledHardfork, getRewardFund, getVestingDelegations nodes, generic method to validate fields, and error handling for each node.
0.0.2 - 2018-01-27
  • Added getContent, getContentReplies, getDiscussionsByAuthorBeforeDate, getRepliesByLastUpdate, getContent, getContentReplies, getDiscussionsByAuthorBeforeDate, getRepliesByLastUpdate, getActiveWitnesses, getMinerQueue, getWitnessByAccount, getWitnessCount, getWitnesses, getWitnessesByVote nodes
0.0.1 - 2018-01-26
  • Added getAccounts, getAccountCount, getConversionRequests, getAccountHistory, getOwnerHistory, getRecoveryRequest nodes



Posted on Utopian.io - Rewarding Open Source Contributors

Sort:  

Hey @jaysermendez I am @utopian-io. I have just upvoted you!

Achievements

  • You have less than 500 followers. Just gave you a gift to help you succeed!
  • Seems like you contribute quite often. AMAZING!

Community-Driven Witness!

I am the first and only Steem Community-Driven Witness. Participate on Discord. Lets GROW TOGETHER!

mooncryption-utopian-witness-gif

Up-vote this comment to grow my power and help Open Source contributions like this one. Want to chat? Join me on Discord https://discord.gg/Pc8HG9x

Thank you for the contribution. It has been approved.

You can contact us on Discord.
[utopian-moderator]

Coin Marketplace

STEEM 0.04
TRX 0.33
JST 0.102
BTC 62777.99
ETH 1796.46
USDT 1.00
SBD 0.38