-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
13 changed files
with
758 additions
and
533 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,6 +2,7 @@ node_modules | |
npm-debug.log | ||
yarn.lock | ||
*data.json | ||
*data* | ||
*.db | ||
.idea/ | ||
*.bak | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,28 @@ | ||
var port = process.env.OPENSHIFT_NODEJS_PORT || process.env.VCAP_APP_PORT || process.env.PORT || process.argv[2] || 8080; | ||
|
||
var Gun = require('../'); | ||
|
||
var server = require('http').createServer(function(req, res){ | ||
if(Gun.serve(req, res)){ return } // filters gun requests! | ||
require('fs').createReadStream(require('path').join(__dirname, req.url)).on('error',function(){ // static files! | ||
res.writeHead(200, {'Content-Type': 'text/html'}); | ||
res.end(require('fs') | ||
.readFileSync(require('path') | ||
.join(__dirname, 'index.html') // or default to index | ||
)); | ||
}).pipe(res); // stream | ||
}); | ||
|
||
var gun = Gun({ | ||
file: 'data.json', | ||
web: server, | ||
s3: { | ||
key: '', // AWS Access Key | ||
secret: '', // AWS Secret Token | ||
bucket: '' // The bucket you want to save into | ||
} | ||
}); | ||
|
||
var server = require('http').createServer(function(req, res){ | ||
if(gun.wsp.server(req, res)){ | ||
return; // filters gun requests! | ||
} | ||
require('fs').createReadStream(require('path').join(__dirname, req.url)).on('error',function(){ // static files! | ||
res.writeHead(200, {'Content-Type': 'text/html'}); | ||
res.end(require('fs').readFileSync(require('path').join(__dirname, 'index.html'))); // or default to index | ||
}).pipe(res); // stream | ||
}); | ||
gun.wsp(server); | ||
server.listen(port); | ||
|
||
console.log('Server started on port ' + port + ' with /gun'); |
Oops, something went wrong.