git ssb

3+

ev / decent



Commit 417aea0d744c82508e6dfb0bc54f635e9578b341

serve invites at /invite/

Ev Bogue committed on 8/30/2017, 5:42:01 PM
Parent: 9c4fb40a5895ae6b15a97fd152cb7698b6cee509

Files changed

serve.jschanged
serve.jsView
@@ -1,20 +1,40 @@
11 var http = require('http');
22 var serve = require('ecstatic');
33 var client = require('./plugins/ssb-client')
4 +var h = require('hyperscript')
45
56 exports.serve = function() {
6- http.createServer(
7- serve({ root: __dirname + '/build/'})
8- ).listen(3001);
9-
7 +
8 + host = 'http://localhost:3001'
9 + title = 'decent'
1010 opts = {"modern": true}
11-
12- client(function (err, sbot) {
13- if(err) throw err
14- sbot.invite.create(opts, function (err, invite) {
15- if(err) throw err
16- var lite = invite
17- console.log('Your lite client is now listening at http://localhost:3001\nHere\'s an invite\nhttp://localhost:3001#' + invite)
18- })
19- })
11 +
12 + http.createServer(function (req, res){
13 + if (req.url === '/') {
14 + serve({ root: __dirname + '/build/'})
15 + }
16 + if (req.url === '/invite/') {
17 + client(function (err, sbot) {
18 + sbot.invite.create(opts, function (err, invite) {
19 + if(err) throw err
20 + lite = invite
21 + gotInvite()
22 + sbot.close()
23 + })
24 + })
25 + function gotInvite() {
26 + res.end(
27 + h('html',
28 + h('head',
29 + h('title', title),
30 + ),
31 + h('body',
32 + h('div.msg',
33 + h('p', {innerHTML: '<a href="' + host + '#' + lite + '" rel="nofollow" target="_blank">'+ host + '#' + lite + '</a>'})
34 + )
35 + )
36 + ).outerHTML)
37 + }
38 + }
39 + }).listen(3001)
2040 }

Built with git-ssb-web