Hello! I am @lemony-cricket, and this is my first Utopian contribution! I did some work on the SteemCleaners API originally developed by
@howo. I added a big new feature (REST API) and also made some small fixes.
(logo taken from GitHub repository; licence (MIT))
Repository
https://github.com/drov0/sc-api (link to merged pull request)
New Features
REST API
The main new feature is the REST API implementation. The inaugural form of the SteemCleaners API used a single endpoint to process JSON-formatted requests. One of the contributions requested by the maintainer (@howo) was that this be re-worked into a full REST API.
Input
For PUT methods, the REST API accepts data of type application/json containing a single JSON object of the same form as the one returned by a GET request.
- One exception: if specified,
memberswill be ignored in aPUTto/groups/:group.
Output
Response codes and bodies will be as follows. (Note: this is an image due to Steemit formatting constraints. A text version is available in the README on GitHub.
Endpoints
The following endpoints are available with the methods listed. (Note: this is an image due to Steemit formatting constraints. A text version is available in the README on GitHub.
Code Changes
Several changes went into this effort.
- First, the legacy functionality was broken into several more maintainable files with unique responsibilities. Initially it was all contained within one file. link to commit
- The database logic was re-written in order to raise exceptions according to what went wrong, allowing for meaningful error messages to be delivered to the client (another improvement requested by the maintainer). link to new source file
- The authentication logic was reworked to use HTTP Basic authentication. In the prior state, the authentication data was passed as part of the JSON request object. link to commit
- A nested Express.js router structure was implemented to represent each exposed endpoint.
- link to new source tree
legacy.jscontains the legacy API (which is still functional for now).common.jscontains common utility functions used by all of the routers (except the legacy one).rest.jsand therest/directory contain the new REST API.
- link to example new source file (this one is for the
/groups/:groupendpoint)
- link to new source tree
Bug Fixes
- Fixed an issue where multiple
req.sendcalls could be made on the same request object. In many cases we were not returning after callingreq.sendwhich caused a double call and unhandled promise rejection errors in the console.