From 2428fd47c82218f7a02a6adad37386a234ca65c5 Mon Sep 17 00:00:00 2001 From: Austin Peterson Date: Tue, 15 Nov 2016 15:55:31 -0600 Subject: [PATCH] Do the thing. --- .gitignore | 1 + LICENSE | 25 +++++++++++++++++++++++++ package.json | 28 ++++++++++++++++++++++++++++ server.js | 13 +++++++++++++ 4 files changed, 67 insertions(+) create mode 100644 .gitignore create mode 100644 LICENSE create mode 100644 package.json create mode 100644 server.js diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..3c3629e --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +node_modules diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..6c1d472 --- /dev/null +++ b/LICENSE @@ -0,0 +1,25 @@ +Copyright (c) 2016 Austin Peterson + +The following license applies to all parts of this software except as +documented below: + +==== + +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. diff --git a/package.json b/package.json new file mode 100644 index 0000000..6e69a5d --- /dev/null +++ b/package.json @@ -0,0 +1,28 @@ +{ + "name": "node-urandom-server", + "version": "1.0.0", + "description": "A node.js web server that just serves from /dev/urandom.", + "main": "server.js", + "scripts": { + "test": "echo \"Error: no test specified\" && exit 1" + }, + "repository": { + "type": "git", + "url": "git+https://github.com/AKPWebDesign/node-urandom-server.git" + }, + "keywords": [ + "urandom", + "express", + "random" + ], + "author": "Austin Peterson (https://blog.akpwebdesign.com)", + "license": "MIT", + "bugs": { + "url": "https://github.com/AKPWebDesign/node-urandom-server/issues" + }, + "homepage": "https://github.com/AKPWebDesign/node-urandom-server#readme", + "dependencies": { + "express": "^4.14.0", + "randbytes": "0.0.1" + } +} diff --git a/server.js b/server.js new file mode 100644 index 0000000..d3dd606 --- /dev/null +++ b/server.js @@ -0,0 +1,13 @@ +var e = require('express') +var a = e() +var p = process.env.PORT || 8080 +var r = new (require('randbytes')).urandom.getInstance() + +a.get('/', (req, res) => { + r.getRandomBytes(5000, (b) => { + res.header('Content-Type', 'text/html') + res.send(b) + }) +}) + +a.listen(p, () => { console.log(`Listening on port ${p}.`) })