mirror of
https://github.com/amark/gun.git
synced 2025-10-13 16:49:26 +00:00
touching app.js
This commit is contained in:
parent
b83b13a1b9
commit
93e34f364b
10
.travis.yml
10
.travis.yml
@ -1,6 +1,6 @@
|
||||
language: node_js
|
||||
node_js:
|
||||
- 0.6
|
||||
- 0.8
|
||||
- 0.10
|
||||
language: node_js
|
||||
node_js:
|
||||
- 0.6
|
||||
- 0.8
|
||||
- 0.10
|
||||
- 0.11
|
130
README.md
130
README.md
@ -1,65 +1,65 @@
|
||||
gun [](https://travis-ci.org/amark/gun)
|
||||
===
|
||||
|
||||
Quick getting started guide.
|
||||
|
||||
Make sure you already have node and npm installed.
|
||||
|
||||
`npm install gun`
|
||||
|
||||
Then require it in your app.
|
||||
|
||||
`var Gun = require('gun');`
|
||||
|
||||
Then initialize a gun instance with your AWS S3 credentials.
|
||||
|
||||
```JavaScript
|
||||
var gun = Gun({
|
||||
s3: {
|
||||
key: '', // AWS Access Key
|
||||
secret: '', // AWS Secret Token
|
||||
bucket: '' // The bucket you want to save into
|
||||
}});
|
||||
```
|
||||
|
||||
S3 is the default persistence layer, it can be replaced with others.
|
||||
|
||||
Currently, gun is only key/value but graph support is coming soon.
|
||||
|
||||
Save your first object, and create a reference to it.
|
||||
|
||||
`gun.set({ hello: 'world' }).key('my/first/data');`
|
||||
|
||||
Now, altogether, with the node hello world web server that replies with your data.
|
||||
|
||||
```JavaScript
|
||||
var Gun = require('gun');
|
||||
var gun = Gun({
|
||||
s3: {
|
||||
key: '', // AWS Access Key
|
||||
secret: '', // AWS Secret Token
|
||||
bucket: '' // The bucket you want to save into
|
||||
}});
|
||||
gun.set({ hello: 'world' }).key('my/first/data');
|
||||
|
||||
var http = require('http');
|
||||
http.createServer(function (req, res) {
|
||||
gun.load('my/first/data', function(data){
|
||||
res.writeHead(200, {'Content-Type': 'application/json'});
|
||||
res.end(JSON.stringify(data));
|
||||
});
|
||||
}).listen(1337, '127.0.0.1');
|
||||
console.log('Server running at http://127.0.0.1:1337/');
|
||||
```
|
||||
|
||||
Now fire up your browser and hit that URL - you'll see your data, plus some gun specific metadata.
|
||||
|
||||
## Ahead
|
||||
- Realtime push to the browser
|
||||
- Persistence in the browser
|
||||
- Authorization callbacks
|
||||
- Graph manipulation
|
||||
- Server to server communication
|
||||
- Test more
|
||||
- Bug fixes
|
||||
- More via additional module hooks (schema, queries, etc.)
|
||||
gun [](https://travis-ci.org/amark/gun)
|
||||
===
|
||||
|
||||
Quick getting started guide.
|
||||
|
||||
Make sure you already have node and npm installed.
|
||||
|
||||
`npm install gun`
|
||||
|
||||
Then require it in your app.
|
||||
|
||||
`var Gun = require('gun');`
|
||||
|
||||
Then initialize a gun instance with your AWS S3 credentials.
|
||||
|
||||
```JavaScript
|
||||
var gun = Gun({
|
||||
s3: {
|
||||
key: '', // AWS Access Key
|
||||
secret: '', // AWS Secret Token
|
||||
bucket: '' // The bucket you want to save into
|
||||
}});
|
||||
```
|
||||
|
||||
S3 is the default persistence layer, it can be replaced with others.
|
||||
|
||||
Currently, gun is only key/value but graph support is coming soon.
|
||||
|
||||
Save your first object, and create a reference to it.
|
||||
|
||||
`gun.set({ hello: 'world' }).key('my/first/data');`
|
||||
|
||||
Now, altogether, with the node hello world web server that replies with your data.
|
||||
|
||||
```JavaScript
|
||||
var Gun = require('gun');
|
||||
var gun = Gun({
|
||||
s3: {
|
||||
key: '', // AWS Access Key
|
||||
secret: '', // AWS Secret Token
|
||||
bucket: '' // The bucket you want to save into
|
||||
}});
|
||||
gun.set({ hello: 'world' }).key('my/first/data');
|
||||
|
||||
var http = require('http');
|
||||
http.createServer(function (req, res) {
|
||||
gun.load('my/first/data', function(data){
|
||||
res.writeHead(200, {'Content-Type': 'application/json'});
|
||||
res.end(JSON.stringify(data));
|
||||
});
|
||||
}).listen(1337, '127.0.0.1');
|
||||
console.log('Server running at http://127.0.0.1:1337/');
|
||||
```
|
||||
|
||||
Now fire up your browser and hit that URL - you'll see your data, plus some gun specific metadata.
|
||||
|
||||
## Ahead
|
||||
- Realtime push to the browser
|
||||
- Persistence in the browser
|
||||
- Authorization callbacks
|
||||
- Graph manipulation
|
||||
- Server to server communication
|
||||
- Test more
|
||||
- Bug fixes
|
||||
- More via additional module hooks (schema, queries, etc.)
|
||||
|
@ -1,25 +1,26 @@
|
||||
console.log("If modules not found, run `npm install` in example/admin folder!");
|
||||
|
||||
var port = process.env.OPENSHIFT_NODEJS_PORT || process.env.VCAP_APP_PORT || process.env.PORT || 8888;
|
||||
var express = require('express');
|
||||
var bodyParser = require('body-parser');
|
||||
var app = express();
|
||||
var Gun = require('gun');
|
||||
var gun = Gun({
|
||||
peers: 'http://localhost:' + port + '/gun'
|
||||
,s3: require('../../test/shotgun') // replace this with your own keys!
|
||||
});
|
||||
|
||||
app.use(express.static(__dirname))
|
||||
.use(bodyParser.json())
|
||||
.use(gun.server);
|
||||
app.listen(port);
|
||||
|
||||
console.log('Express started on port ' + port + ' with /gun');
|
||||
|
||||
gun.load('blob/data', function(){ // ugh need to initialize the data if there is none, what a waste of LOC!
|
||||
gun.set({_:{'#': "yVbyf7BqlXVQQUOE5cw9rf8h",'>':{hello: 1407328713707,from: 1407328713707}}, // this is a nasty trick to force the ID to overwrite itself
|
||||
hello: "world",
|
||||
from: "Mark Nadal"
|
||||
}).key('blob/data');
|
||||
console.log("HEY YOU");
|
||||
console.log("If modules not found, run `npm install` in example/admin folder!");
|
||||
|
||||
var port = process.env.OPENSHIFT_NODEJS_PORT || process.env.VCAP_APP_PORT || process.env.PORT || 8888;
|
||||
var express = require('express');
|
||||
var bodyParser = require('body-parser');
|
||||
var app = express();
|
||||
var Gun = require('gun');
|
||||
var gun = Gun({
|
||||
peers: 'http://localhost:' + port + '/gun'
|
||||
,s3: require('../../test/shotgun') // replace this with your own keys!
|
||||
});
|
||||
|
||||
app.use(express.static(__dirname))
|
||||
.use(bodyParser.json())
|
||||
.use(gun.server);
|
||||
app.listen(port);
|
||||
|
||||
console.log('Express started on port ' + port + ' with /gun');
|
||||
|
||||
gun.load('blob/data', function(){ // ugh need to initialize the data if there is none, what a waste of LOC!
|
||||
gun.set({_:{'#': "yVbyf7BqlXVQQUOE5cw9rf8h",'>':{hello: 1407328713707,from: 1407328713707}}, // this is a nasty trick to force the ID to overwrite itself
|
||||
hello: "world",
|
||||
from: "Mark Nadal"
|
||||
}).key('blob/data');
|
||||
});
|
@ -1,9 +1,9 @@
|
||||
{
|
||||
"name": "admin",
|
||||
"main": "app.js",
|
||||
"dependencies": {
|
||||
"express": "~>4.9.0",
|
||||
"body-parser": "~>1.8.1",
|
||||
"gun": "~>0.0.2b"
|
||||
}
|
||||
{
|
||||
"name": "admin",
|
||||
"main": "app.js",
|
||||
"dependencies": {
|
||||
"express": "~>4.9.0",
|
||||
"body-parser": "~>1.8.1",
|
||||
"gun": "~>0.0.2b"
|
||||
}
|
||||
}
|
@ -1,64 +1,64 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<style>
|
||||
.table li {
|
||||
float: left;
|
||||
min-width: 200px;
|
||||
max-width: 400px;
|
||||
}
|
||||
ul, li {
|
||||
list-style: none;
|
||||
}
|
||||
.clear {
|
||||
clear: both;
|
||||
}
|
||||
.none {
|
||||
display: none;
|
||||
}
|
||||
</style>
|
||||
<ul>
|
||||
<li><ul class="table none">
|
||||
<li>Seconds in month:</li>
|
||||
<li><input type="number" value="2629743.83" id="sim"></li>
|
||||
</ul></li>
|
||||
<li class="clear"></li>
|
||||
<li><ul class="table">
|
||||
<li>Persist every seconds:</li>
|
||||
<li><input type="number" value="15" id="se"></li>
|
||||
</ul></li>
|
||||
<li class="clear"></li>
|
||||
<li><ul class="table">
|
||||
<li>Over how many objects:</li>
|
||||
<li><input type="number" value="100" id="o"></li>
|
||||
</ul></li>
|
||||
<li class="clear"></li>
|
||||
<li><ul class="table">
|
||||
<li>Cost $:</li>
|
||||
<li><input type="number" value="" readonly id="r"></li>
|
||||
</ul></li>
|
||||
</ul>
|
||||
<br>
|
||||
<p>
|
||||
This page is for throughput calculation, it assumes continuous load non-stop.
|
||||
</p>
|
||||
<script>
|
||||
$(function(){
|
||||
var sim = $('#sim')
|
||||
, se = $('#se')
|
||||
, o = $('#o')
|
||||
, r = $('#r')
|
||||
, n = function(n){ return parseFloat(n) }
|
||||
$(document).on('keyup', function(){
|
||||
r.val(
|
||||
(( n(sim.val()) / n(se.val()) ) * n(o.val()) / 1000 * 0.005 ).toFixed(2)
|
||||
);
|
||||
})
|
||||
})
|
||||
</script>
|
||||
</body>
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<style>
|
||||
.table li {
|
||||
float: left;
|
||||
min-width: 200px;
|
||||
max-width: 400px;
|
||||
}
|
||||
ul, li {
|
||||
list-style: none;
|
||||
}
|
||||
.clear {
|
||||
clear: both;
|
||||
}
|
||||
.none {
|
||||
display: none;
|
||||
}
|
||||
</style>
|
||||
<ul>
|
||||
<li><ul class="table none">
|
||||
<li>Seconds in month:</li>
|
||||
<li><input type="number" value="2629743.83" id="sim"></li>
|
||||
</ul></li>
|
||||
<li class="clear"></li>
|
||||
<li><ul class="table">
|
||||
<li>Persist every seconds:</li>
|
||||
<li><input type="number" value="15" id="se"></li>
|
||||
</ul></li>
|
||||
<li class="clear"></li>
|
||||
<li><ul class="table">
|
||||
<li>Over how many objects:</li>
|
||||
<li><input type="number" value="100" id="o"></li>
|
||||
</ul></li>
|
||||
<li class="clear"></li>
|
||||
<li><ul class="table">
|
||||
<li>Cost $:</li>
|
||||
<li><input type="number" value="" readonly id="r"></li>
|
||||
</ul></li>
|
||||
</ul>
|
||||
<br>
|
||||
<p>
|
||||
This page is for throughput calculation, it assumes continuous load non-stop.
|
||||
</p>
|
||||
<script>
|
||||
$(function(){
|
||||
var sim = $('#sim')
|
||||
, se = $('#se')
|
||||
, o = $('#o')
|
||||
, r = $('#r')
|
||||
, n = function(n){ return parseFloat(n) }
|
||||
$(document).on('keyup', function(){
|
||||
r.val(
|
||||
(( n(sim.val()) / n(se.val()) ) * n(o.val()) / 1000 * 0.005 ).toFixed(2)
|
||||
);
|
||||
})
|
||||
})
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
@ -1,17 +1,17 @@
|
||||
var Gun = require('gun');
|
||||
var gun = Gun({
|
||||
s3: {
|
||||
key: '', // AWS Access Key
|
||||
secret: '', // AWS Secret Token
|
||||
bucket: '' // The bucket you want to save into
|
||||
}});
|
||||
gun.set({ hello: 'world' }).key('my/first/data')
|
||||
|
||||
var http = require('http');
|
||||
http.createServer(function (req, res) {
|
||||
gun.load('my/first/data', function(data){
|
||||
res.writeHead(200, {'Content-Type': 'application/json'});
|
||||
res.end(JSON.stringify(data));
|
||||
});
|
||||
}).listen(1337, '127.0.0.1');
|
||||
var Gun = require('gun');
|
||||
var gun = Gun({
|
||||
s3: {
|
||||
key: '', // AWS Access Key
|
||||
secret: '', // AWS Secret Token
|
||||
bucket: '' // The bucket you want to save into
|
||||
}});
|
||||
gun.set({ hello: 'world' }).key('my/first/data')
|
||||
|
||||
var http = require('http');
|
||||
http.createServer(function (req, res) {
|
||||
gun.load('my/first/data', function(data){
|
||||
res.writeHead(200, {'Content-Type': 'application/json'});
|
||||
res.end(JSON.stringify(data));
|
||||
});
|
||||
}).listen(1337, '127.0.0.1');
|
||||
console.log('Server running at http://127.0.0.1:1337/');
|
@ -5,12 +5,12 @@
|
||||
</head>
|
||||
<body>
|
||||
<style>
|
||||
html, body {
|
||||
html, body {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
font-family: 'Segoe UI', Tahoma;
|
||||
font-size: 20pt;
|
||||
color: #222;
|
||||
color: #222;
|
||||
}
|
||||
@media (max-width: 1000px){
|
||||
html, body {
|
||||
@ -32,18 +32,18 @@
|
||||
-moz-animation: fade 7s;
|
||||
animation: fade 7s;
|
||||
}
|
||||
.big {
|
||||
font-size: 300%;
|
||||
.big {
|
||||
font-size: 300%;
|
||||
}
|
||||
.small {
|
||||
font-size: 75%;
|
||||
.small {
|
||||
font-size: 75%;
|
||||
}
|
||||
.break {
|
||||
border: none;
|
||||
border-bottom: dashed 5px gainsboro;
|
||||
border-bottom: dashed 5px gainsboro;
|
||||
}
|
||||
.bump {
|
||||
height: 20%;
|
||||
.bump {
|
||||
height: 20%;
|
||||
}
|
||||
|
||||
@-webkit-keyframes fade {
|
||||
|
Loading…
x
Reference in New Issue
Block a user