## Zac's Decentralised Data Store
npm install zdds* https://www.npmjs.com/package/zdds-interface
* https://gitlab.com/imzacm/zddsInterface
Nodes can be run accross one computer, inside a local network, or over the internet.
There are currently two nodes on the internet:
* https://radiant-ocean-90908.herokuapp.com:443
* http://132.148.136.120:3985
ZDDS can be used as a standalone server, or within a project.
To use it inside a project, do the following:
```
yarn add zdds
const opts = {} // Add the options below as key/value pairs
const Node = require('zdds').Node
const node = new Node(opts)
| Event | Args | When fired |
|---------|--------------------------------------|-------------------------------|
| created | Options passed into `new Node()` | On end of `constructor()` |`
| started | port` | On end on `start()` |`
| stopped | port` | One end of `stop()` |`
| synced | Types passed into sync()` | On end of `sync()` |`
| pushed | {key, value}` | On end of `push()` |`
| deleted | key` | On end of `delete()` |`
| request | {path, method}` | On request to server |
This should run on windows as well, however I don't use windows so it might require different commands.
I recommend using yarn, however npm should work too.
If using npm, change yarn to npm in the below commands.
* Install NodeJS and optionally Yarn
* `git clone https://gitlab.com/imzacm/Decentralise.git``
* cd Decentralise``
* yarn install``
* yarn start`
To install it as a global node module instead, do the following:
``
yarn global add zdds
zdds
If you installed it as a global node module, you can run `yarn global upgrade zdds` and then restart the server.
If you installed through git, you can run `node update.js` while the server is running and it will automatically restart.
``
export =
yarn start
Or
``
yarn start =`$3
The default port is 3985 however this can be changed by setting the port` option.
#### Default
localhost
#### Default
true
This will not stop other nodes from pushing the nodes and data they have to the instance if they know it exists.
#### Default
10000
This will be entirely separate from the first node.
#### Default
true
* data: data object
* nodes: nodes object
#### Default
3986
* /info
* /data
* /nodes
* / - loads this readme
{
"id": A unique GUID generated the first time the server is started,
"version": The version of ZDDS running the node,
"appName": The name in package.json,
"port": The port the server is running on,
"protocol": The protocol the server is running on - http or https,
"host": The ip/domain to access the server
}
`$3
#### SEND HEADERS:
key: The key to retrieve from ZDDS, if undefined then all data will be returned#### HEADERS:
Content-Type: 'application/json'
timestamp: 1517742716662
#### BODY:
`
{
"key": {
"value": ,
"timestamp": 1517742716662
}
}
`$3
#### SEND HEADERS:
nodeId: The id of a node to retrieve, if undefined then all nodes will be returned#### HEADERS:
Content-Type: 'application/json'
timestamp: 1517742716662
#### BODY:
`
{
"id": {
"host": The ip/domain the host can be accessed on,
"port": The port the server is running on,
"protocol": The protocol the server is using - http or https
}
}
`$3
#### HEADERS:
Content-Type: 'application/json' timestamp: 1517742716662
#### BODY:
`
{
"error": "Some error message"
}
`Available POST endpoints:
* /data
* /nodes
* /delete
$3
#### BODY:
`
{
"id": {
"host": The ip/domain the host can be accessed on,
"port": The port the server is running on,
"protocol": The protocol the server is using - http or https
}
}
`#### HEADERS:
Content-Type: 'application/json'
timestamp: 1517742716662
#### BODY:
An object containing every node that this node knows about.
$3
#### Reserved keys
The following keys are reserved:
* postId
* dataObj
* timestamp
#### BODY:
`
{
"aKey": "a value",
"postId": The postId needed to overwrite an existing key
}
`#### HEADERS:
Content-Type: 'application/json'
timestamp: 1517742716662
#### BODY:
`
{
"keyThatWasSent": value,
"postId": The postId needed to overwrite the key
}
` ### Example of POST to /delete:
#### BODY:
`
{
"aKey": "a value",
"postId": The postId needed to overwrite an existing key
}
`#### HEADERS:
Content-Type: 'application/json'
timestamp: 1517742716662
#### BODY:
`
{}
``