diff --git a/examples/admin/app.js b/examples/admin/app.js index 20fb878a..45845522 100644 --- a/examples/admin/app.js +++ b/examples/admin/app.js @@ -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 diff --git a/hello-world.js b/hello-world.js new file mode 100644 index 00000000..323d2861 --- /dev/null +++ b/hello-world.js @@ -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/'); \ No newline at end of file