Gun data API executer
Execute Gun.js API via structured data.
Why?
A structured data API is useful for clients who don't have direct access to the gun
instance or the Javascript environment.
The "raison d'être" was an attempt to use Gun from Elm, a foreign client environment. With gun exec we can do:
let execute = appportsgunCommander
Install
npm: npm i -S gun-exec
(soon)
yarn: yarn add gun-exec
(soon)
from github: npm i -S kristianmandrup/gun-exec
Dependencies
gun
v. 0.6 or higher
Usage
Assumes Babel.js or similar transpiler setup
const gun = ; let execute = // equivalent to: gun.get('colors').put({color: 'blue'}) let cols = // ...
Using structured commands in the form name
and args
For mutations such as set
and put
you can use explicit model
option
You can mix and match these command declaration variants as you like
Special options:
root: true
: resets the chain context to the gun instance.
Advanced example
let blue =
Here we override the logging setting of this execute
context via logging: false
option in the final (optional) argument.
Elm usage
Contributing
Install dependency modules/packages
npm i
Compile/Build
The project includes a gulpfile
configured to use Babel 6.
All /src
files are compiled to /dist
including source maps.
Scripts:
- start:
npm start
- build:
npm run build
(ie. compile) - watch and start:
npm run watch
- watch and build:
npm run watch:b
Run Tests
npm test
or simply ava test
License
MIT Kristian Mandrup