Real-time json cache for blockchain data.
feathers-giveth uses Feathersjs as a json cache for blockchain transaction history. The purpose is to ameliorate user wait times.
Feathersjs provides both a rest and websocket interface to database. Data itself is stored on the server file system use NeDB.
While this does nothing to speedup blockchain responses, it allows everyone connected to receive aggregate updates immediately via socketio push (aka pub/sub). This should hopefully simplify the code for the MVP, as it will not have worry about polling for all updates.
Getting up and running is as easy as 1, 2, 3.
-
Install your dependencies
cd path/to/feathers-giveth; yarn install
-
Start your app
yarn start
-
start a production server
yarn serve
Simply run yarn test
and all your tests in the test/
directory will be run.
Each of these services are available via rest or websocket:
givers
donations
milestones
reviewer-requests
completion-requests
projects
causes
campaigns
skunkworks
To add another service use (after installing the feathers cli):
feathers generate service
Choose defaults for options as described here
Example to store new json object:
curl 'http://secret.com:3030/skunkworks/' -H 'Content-Type: application/json' --data-binary '{ "name": "Curler", "text": "Hello from the command line!" }'
Example to remove all json objects:
curl 'http://secret.com:3030/skunkworks/' -X "DELETE"
You may call these services from client web app using the feathers api.
Example to connect to donations service:
const socket = io();
const client = feathers();
client.configure(feathers.socketio(socket));
const donations = client.service('donations');
Example to get donation data from server db and do something for each stored json object (notice pagination):
donations.find().then(page => page.data.forEach(doSomethingWithJsonObject));
Example to subscribe to donations service create event assign it to named function:
donations.on('created', doSomethingWithJsonObject);
Using a microservice approach, services are seperated into seperate json databases (which are really just json data files on the server).
Currenlty there are no enforced fields for json objects. Required fields and types may be introduced later with hooks.
Currently there are no hooks but they can and will be added as a convenient way to execute operations that must occur on all requests (e.g. authorization, validation).
Checkout Feathersjs api service methods and service events and database querying.
0.1.0
- Initial release
Copyright (c) 2016
Licensed under the MIT license.