diff --git a/controllers/website.js b/controllers/website.js new file mode 100644 index 0000000..5cb775b --- /dev/null +++ b/controllers/website.js @@ -0,0 +1,23 @@ +let express = require('express'); +let router = express.Router(); +let fs = require('fs'); +let mustache = require('mustache'); +let lightning = require('../lightning'); + +router.get('/', function(req, res) { + let html = fs.readFileSync('./templates/index.html').toString('utf8'); + lightning.getInfo({}, function(err, info) { + if (err) { + console.error('lnd failure'); + process.exit(3); + } + res.setHeader('Content-Type', 'text/html'); + return res.status(200).send(mustache.render(html, info)); + }); +}); + +router.use(function(req, res) { + res.status(404).send('404'); +}); + +module.exports = router; diff --git a/index.js b/index.js index ad23142..2942aec 100644 --- a/index.js +++ b/index.js @@ -30,6 +30,7 @@ app.use(bodyParser.urlencoded({ extended: false })); // parse application/x-www- app.use(bodyParser.json(null)); // parse application/json app.use(require('./controllers/api')); +app.use(require('./controllers/website')); let server = app.listen(process.env.PORT || 3000, function() { logger.log('BOOTING UP', 'Listening on port ' + (process.env.PORT || 3000)); diff --git a/package-lock.json b/package-lock.json index 65fa0d6..915fc77 100644 --- a/package-lock.json +++ b/package-lock.json @@ -2265,13 +2265,11 @@ }, "balanced-match": { "version": "1.0.0", - "bundled": true, - "optional": true + "bundled": true }, "brace-expansion": { "version": "1.1.11", "bundled": true, - "optional": true, "requires": { "balanced-match": "^1.0.0", "concat-map": "0.0.1" @@ -2284,18 +2282,15 @@ }, "code-point-at": { "version": "1.1.0", - "bundled": true, - "optional": true + "bundled": true }, "concat-map": { "version": "0.0.1", - "bundled": true, - "optional": true + "bundled": true }, "console-control-strings": { "version": "1.1.0", - "bundled": true, - "optional": true + "bundled": true }, "core-util-is": { "version": "1.0.2", @@ -2398,8 +2393,7 @@ }, "inherits": { "version": "2.0.3", - "bundled": true, - "optional": true + "bundled": true }, "ini": { "version": "1.3.5", @@ -2409,7 +2403,6 @@ "is-fullwidth-code-point": { "version": "1.0.0", "bundled": true, - "optional": true, "requires": { "number-is-nan": "^1.0.0" } @@ -2422,20 +2415,17 @@ "minimatch": { "version": "3.0.4", "bundled": true, - "optional": true, "requires": { "brace-expansion": "^1.1.7" } }, "minimist": { "version": "0.0.8", - "bundled": true, - "optional": true + "bundled": true }, "minipass": { "version": "2.2.4", "bundled": true, - "optional": true, "requires": { "safe-buffer": "^5.1.1", "yallist": "^3.0.0" @@ -2452,7 +2442,6 @@ "mkdirp": { "version": "0.5.1", "bundled": true, - "optional": true, "requires": { "minimist": "0.0.8" } @@ -2525,8 +2514,7 @@ }, "number-is-nan": { "version": "1.0.1", - "bundled": true, - "optional": true + "bundled": true }, "object-assign": { "version": "4.1.1", @@ -2536,7 +2524,6 @@ "once": { "version": "1.4.0", "bundled": true, - "optional": true, "requires": { "wrappy": "1" } @@ -2642,7 +2629,6 @@ "string-width": { "version": "1.0.2", "bundled": true, - "optional": true, "requires": { "code-point-at": "^1.0.0", "is-fullwidth-code-point": "^1.0.0", @@ -3956,6 +3942,11 @@ "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", "integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g=" }, + "mustache": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/mustache/-/mustache-3.0.1.tgz", + "integrity": "sha512-jFI/4UVRsRYdUbuDTKT7KzfOp7FiD5WzYmmwNwXyUVypC0xjoTL78Fqc0jHUPIvvGD+6DQSPHIt1NE7D1ArsqA==" + }, "mute-stream": { "version": "0.0.7", "resolved": "https://registry.npmjs.org/mute-stream/-/mute-stream-0.0.7.tgz", diff --git a/package.json b/package.json index 08fdf78..9836c51 100644 --- a/package.json +++ b/package.json @@ -29,6 +29,7 @@ "ioredis": "^4.2.0", "jayson": "^2.1.0", "morgan": "^1.9.1", + "mustache": "^3.0.1", "node-uuid": "^1.4.8", "prettier": "^1.15.3", "request": "^2.88.0", diff --git a/templates/index.html b/templates/index.html new file mode 100644 index 0000000..f63e84d --- /dev/null +++ b/templates/index.html @@ -0,0 +1,530 @@ + + + + + + + + + + + + + LndHub + + + + + +
+ +
+
+
 _________________________
+
/ Hi! How are you?        \
+
|                         |
+
\ Welcome to LNDHUB!      /
+
 -------------------------
+
        \   ^__^
+
         \  (oo)\_______
+
            (__)\       )\/\
+
                ||----w |
+
                ||     ||
+ +
 
+
 
+
 
+
Hello world!
+
Welcome to LndHub, opensource wrapper for Lightning Network Daemon
+
It provides separate accounts and trust minimization for end users
+
 
+
LND uris:
+ {{#uris}} +
{{.}}
+ {{/uris}} +
 
+
num_active_channels:
+
{{num_active_channels}}
+
 
+
num_peers:
+
{{num_peers}}
+
 
+
version:
+
{{version}}
+
 
+
Fork me on GitHub!
+
https://github.com/BlueWallet/LndHub
+
 
+
Start using it on MainNet (zero configuration required):
+
https://bluewallet.io
+
 
+
 
+
 
+
+
+ +
+
+ $ +
+ +
+ +
+ + + + + \ No newline at end of file