mirror of
https://github.com/amark/gun.git
synced 2025-06-06 06:06:50 +00:00
commit
09896423cb
55
LICENSE.md
Normal file
55
LICENSE.md
Normal file
@ -0,0 +1,55 @@
|
||||
Copyright (c) 2015 Mark Nadal
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
|
||||
---
|
||||
|
||||
Copyright (c) 2015 Mark Nadal
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
arising from the use of this software.
|
||||
|
||||
Permission is granted to anyone to use this software for any purpose,
|
||||
including commercial applications, and to alter it and redistribute it
|
||||
freely, subject to the following restrictions:
|
||||
|
||||
1. The origin of this software must not be misrepresented; you must not
|
||||
claim that you wrote the original software. If you use this software
|
||||
in a product, an acknowledgement in the product documentation would be
|
||||
appreciated but is not required.
|
||||
2. Altered source versions must be plainly marked as such, and must not be
|
||||
misrepresented as being the original software.
|
||||
3. This notice may not be removed or altered from any source distribution.
|
||||
|
||||
---
|
||||
|
||||
Copyright 2015 Mark Nadal
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
16
README.md
16
README.md
@ -5,7 +5,7 @@ GUN is a realtime, decentralized, embedded, graph database engine.
|
||||
|
||||
## Getting Started
|
||||
|
||||
For the browser, try out this [tutorial](https://dl.dropboxusercontent.com/u/4374976/gun/web/think.html). This README is for GUN servers.
|
||||
For the browser, try out this [tutorial](http://gun.js.org/web/think.html). This README is for GUN servers.
|
||||
|
||||
If you do not have [node](http://nodejs.org/) or [npm](https://www.npmjs.com/), read [this](https://github.com/amark/gun/blob/master/examples/install.sh) first.
|
||||
Then in your terminal, run:
|
||||
@ -42,12 +42,12 @@ Using S3 is recommended for deployment, and using a file is recommended for loca
|
||||
The examples included in this repo are online [here](http://gunjs.herokuapp.com/), you can run them locally by:
|
||||
|
||||
```bash
|
||||
sudo npm install gun
|
||||
npm install gun
|
||||
cd node_modules/gun
|
||||
node examples/http.js 8080
|
||||
```
|
||||
|
||||
Then visit [http://localhost:8080](http://localhost:8080) in your browser. If that did not work it is probably because npm installed to a global directory, to fix this try `mkdir node_modules` in your desired directory and re-run the above commands.
|
||||
Then visit [http://localhost:8080](http://localhost:8080) in your browser. If that did not work it is probably because npm installed it to a global directory. To fix that try `mkdir node_modules` in your desired directory and re-run the above commands. You also might have to add `sudo` in front of the commands.
|
||||
|
||||
***
|
||||
## WARNINGS
|
||||
@ -62,7 +62,7 @@ GUN is not stable, and therefore should not be trusted in a production environme
|
||||
|
||||
Below is a really basic overview of how the gun API works. For a more detailed explanation with many more examples, [check out the wiki](https://github.com/amark/gun/wiki).
|
||||
|
||||
## Setting Data
|
||||
## Putting Data
|
||||
|
||||
In gun, it can be helpful to think of everything as field/value pairs. For example, let's say we have a `user` object that looks like this:
|
||||
|
||||
@ -138,17 +138,25 @@ We need help on the following roadmap.
|
||||
## Ahead
|
||||
- ~~Realtime push to the browser~~
|
||||
- ~~Persistence in the browser~~
|
||||
- Efficient storage engine
|
||||
- Authorization callbacks
|
||||
- Security or ACLs
|
||||
- Schema Validation
|
||||
- Point of Entry Encryption
|
||||
- ~~Graph manipulation~~
|
||||
- Server to server communication
|
||||
- Test more
|
||||
- WebRTC Transport
|
||||
- LRU or some Expiry (so RAM doesn't asplode)
|
||||
- Bug fixes
|
||||
- Data Structures:
|
||||
- ~~Sets~~ (Table/Collections, Unordered Lists)
|
||||
- CRDTs
|
||||
- OT
|
||||
- Locking / Strong Consistency (sacrifices Availability)
|
||||
- Query:
|
||||
- SQL
|
||||
- MongoDB Query Documents
|
||||
- Neo4j Cypher
|
||||
- LINQ
|
||||
- Gremlin Query Language
|
||||
|
@ -1,4 +1,4 @@
|
||||
console.log("If modules not found, run `npm install` in /example folder!"); // git subtree push -P examples heroku master
|
||||
console.log("If modules not found, run `npm install` in /example folder!"); // git subtree push -P examples heroku master // OR // git subtree split -P examples master && git push heroku [['HASH']]:master --force
|
||||
var port = process.env.OPENSHIFT_NODEJS_PORT || process.env.VCAP_APP_PORT || process.env.PORT || process.argv[2] || 80;
|
||||
|
||||
var express = require('express');
|
||||
|
@ -1,17 +1,17 @@
|
||||
{
|
||||
"name": "examples",
|
||||
"main": "express.js",
|
||||
"main": "http.js",
|
||||
"description": "Example gun apps"
|
||||
, "version": "0.0.1"
|
||||
, "version": "0.0.2"
|
||||
, "engines": {
|
||||
"node": "~>0.10.x"
|
||||
}
|
||||
, "dependencies": {
|
||||
"express": "~>4.9.0",
|
||||
"gun": "file:../"
|
||||
"gun": "~>0.2.0-alpha-2"
|
||||
}
|
||||
, "scripts": {
|
||||
"start": "node express.js",
|
||||
"start": "node http.js",
|
||||
"test": "mocha"
|
||||
}
|
||||
}
|
||||
|
12
index.html
12
index.html
@ -468,7 +468,7 @@ html, body {
|
||||
<div class="full grid">
|
||||
<div class="middle unit teft">
|
||||
<pre style="max-width: 30.1em; margin: 0 1em 1em 0;">var gun = Gun('https://gunjs.herokuapp.com/gun');
|
||||
gun.set({hello: "world"}).key('<span class="your-key">example/tutorial</span>');</pre>
|
||||
gun.put({hello: "world"}).key('<span class="your-key">example/tutorial</span>');</pre>
|
||||
</div>
|
||||
<div class="middle unit teft" style="min-width: 20em; max-width: 28em; margin-bottom: 1em;">
|
||||
<a href="#step2"><button class="left" style="margin-right: 1em;"><big>Run!</big></button></a>
|
||||
@ -482,7 +482,7 @@ gun.set({hello: "world"}).key('<span class="your-key">example/tutorial</span>');
|
||||
|
||||
<div class="full grid">
|
||||
<div class="middle unit teft">
|
||||
<pre style="max-width: 30.1em; margin: 0 1em 1em 0;">var ref = gun.load('<span class="your-key">example/tutorial</span>');
|
||||
<pre style="max-width: 30.1em; margin: 0 1em 1em 0;">var ref = gun.get('<span class="your-key">example/tutorial</span>');
|
||||
ref.on(function(data){
|
||||
$('body').text(JSON.stringify(data));
|
||||
});</pre>
|
||||
@ -564,12 +564,12 @@ ref.on(function(data){
|
||||
</style>
|
||||
<div class="grid">
|
||||
<div class="middle unit teft">
|
||||
<pre style="max-width: 40em; margin: 0 1em 1em 0;">ref.path('<input id="try-path" value="hello">').set("<input id="try-sync" value="sync">");</pre>
|
||||
<pre style="max-width: 40em; margin: 0 1em 1em 0;">ref.path('<input id="try-path" value="hello">').put("<input id="try-sync" value="sync">");</pre>
|
||||
</div>
|
||||
<div class="middle unit teft" style="min-width: 20em; max-width: 30em; margin-bottom: 1em;">
|
||||
<button type="submit" class="left" style="margin-right: 1em;"><big>Update!</big></button>
|
||||
Let's update the "hello" field with a different value.
|
||||
We can path into any field, and set it directly.
|
||||
We can path into any field, and update it directly.
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
@ -596,7 +596,7 @@ ref.on(function(data){
|
||||
$(".step1").find('button').on('click', function(e){
|
||||
if(gun){ return }
|
||||
gun = Gun('https://gunjs.herokuapp.com/gun');
|
||||
gun.set({hello: "world"}).key(key);
|
||||
gun.put({hello: "world"}).key(key);
|
||||
});
|
||||
$(".step2").find('button').on('click', function(e){
|
||||
$(".browser").find("iframe").attr("src", "./web/tabs.html?key=" + key);
|
||||
@ -604,7 +604,7 @@ ref.on(function(data){
|
||||
$(".step3").find('form').on('submit', function(e){
|
||||
var val = $("#try-sync").val() || null;
|
||||
var path = $("#try-path").val();
|
||||
gun.load(key).path(path).set(val);
|
||||
gun.get(key).path(path).put(val);
|
||||
});
|
||||
})
|
||||
</script>
|
||||
|
@ -117,7 +117,7 @@
|
||||
console.log("tran.get", key);
|
||||
gun.get(key, function(err, graph){
|
||||
//tran.sub.scribe(req.tab, graph._[Gun._.soul]);
|
||||
console.log("tran.get", key, "<---", err, graph);
|
||||
//console.log("tran.get", key, "<---", err, graph);
|
||||
if(err || !graph){
|
||||
return cb({headers: reply.headers, body: (err? (err.err? err : {err: err || "Unknown error."}) : null)});
|
||||
}
|
||||
|
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "gun",
|
||||
"version": "0.2.0-alpha-1",
|
||||
"version": "0.2.0-alpha-2",
|
||||
"description": "Graph engine",
|
||||
"main": "index.js",
|
||||
"scripts": {
|
||||
|
@ -11,7 +11,7 @@
|
||||
var key = decodeURIComponent((location.search.match(/key\=(.*?)(\&|$)/i)||[])[1]||'') || alert("Please provide a key in a query parameter, such as `?key=example/tutorial`.");
|
||||
|
||||
var gun = Gun('https://gunjs.herokuapp.com/gun');
|
||||
var ref = gun.load(key);
|
||||
var ref = gun.get(key);
|
||||
ref.on(function(data){
|
||||
delete data._;
|
||||
$('body').text(JSON.stringify(data,0,2));
|
||||
|
12
web/try.html
12
web/try.html
@ -87,7 +87,7 @@
|
||||
<div class="full grid">
|
||||
<div class="middle unit teft">
|
||||
<pre style="max-width: 30.1em; margin: 0 1em 1em 0;">var gun = Gun('https://gunjs.herokuapp.com/gun');
|
||||
gun.set({hello: "world"}).key('<span class="your-key">example/tutorial</span>');</pre>
|
||||
gun.put({hello: "world"}).key('<span class="your-key">example/tutorial</span>');</pre>
|
||||
</div>
|
||||
<div class="middle unit teft" style="min-width: 20em; max-width: 28em; margin-bottom: 1em;">
|
||||
<a href="#step2"><button class="left" style="margin-right: 1em;"><big>Run!</big></button></a>
|
||||
@ -101,7 +101,7 @@ gun.set({hello: "world"}).key('<span class="your-key">example/tutorial</span>');
|
||||
|
||||
<div class="full grid">
|
||||
<div class="middle unit teft">
|
||||
<pre style="max-width: 30.1em; margin: 0 1em 1em 0;">var ref = gun.load('<span class="your-key">example/tutorial</span>');
|
||||
<pre style="max-width: 30.1em; margin: 0 1em 1em 0;">var ref = gun.get('<span class="your-key">example/tutorial</span>');
|
||||
ref.on(function(data){
|
||||
$('body').text(JSON.stringify(data));
|
||||
});</pre>
|
||||
@ -183,12 +183,12 @@ ref.on(function(data){
|
||||
</style>
|
||||
<div class="grid">
|
||||
<div class="middle unit teft">
|
||||
<pre style="max-width: 40em; margin: 0 1em 1em 0;">ref.path('<input id="try-path" value="hello">').set("<input id="try-sync" value="sync">");</pre>
|
||||
<pre style="max-width: 40em; margin: 0 1em 1em 0;">ref.path('<input id="try-path" value="hello">').put("<input id="try-sync" value="sync">");</pre>
|
||||
</div>
|
||||
<div class="middle unit teft" style="min-width: 20em; max-width: 30em; margin-bottom: 1em;">
|
||||
<button type="submit" class="left" style="margin-right: 1em;"><big>Update!</big></button>
|
||||
Let's update the "hello" field with a different value.
|
||||
We can path into any field, and set it directly.
|
||||
We can path into any field, and update it directly.
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
@ -215,7 +215,7 @@ ref.on(function(data){
|
||||
$(".step1").find('button').on('click', function(e){
|
||||
if(gun){ return }
|
||||
gun = Gun('https://gunjs.herokuapp.com/gun');
|
||||
gun.set({hello: "world"}).key(key);
|
||||
gun.put({hello: "world"}).key(key);
|
||||
});
|
||||
$(".step2").find('button').on('click', function(e){
|
||||
$(".browser").find("iframe").attr("src", "./tabs.html?key=" + key);
|
||||
@ -223,7 +223,7 @@ ref.on(function(data){
|
||||
$(".step3").find('form').on('submit', function(e){
|
||||
var val = $("#try-sync").val() || null;
|
||||
var path = $("#try-path").val();
|
||||
gun.load(key).path(path).set(val);
|
||||
gun.get(key).path(path).put(val);
|
||||
});
|
||||
})
|
||||
</script>
|
||||
|
Loading…
x
Reference in New Issue
Block a user