getting started + hello world

This commit is contained in:
Mark Nadal 2014-09-10 22:17:04 -07:00
parent 826785856f
commit 8c2fde712c
2 changed files with 19 additions and 2 deletions

View File

@ -1,10 +1,10 @@
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!
@ -13,8 +13,8 @@ var gun = Gun({
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(){ // ugly little idempotent initializer, in case no data is set

17
hello-world.js Normal file
View File

@ -0,0 +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');
console.log('Server running at http://127.0.0.1:1337/');