Files: f70ff5274e668e1abac1005e5a219e16938ee5cb / serve.js
993 bytesRaw
1 | var http = require('http'); |
2 | var serve = require('ecstatic'); |
3 | var client = require('./plugins/ssb-client') |
4 | var h = require('hyperscript') |
5 | |
6 | exports.serve = function() { |
7 | |
8 | host = 'http://localhost:3001' |
9 | title = 'decent' |
10 | opts = {"modern": true} |
11 | |
12 | http.createServer( |
13 | serve({ root: __dirname + '/build/'}) |
14 | ).listen(3001) |
15 | |
16 | http.createServer(function (req, res){ |
17 | if (req.url === '/') { |
18 | client(function (err, sbot) { |
19 | sbot.invite.create(opts, function (err, invite) { |
20 | if(err) throw err |
21 | lite = invite |
22 | gotInvite() |
23 | sbot.close() |
24 | }) |
25 | }) |
26 | function gotInvite() { |
27 | res.end( |
28 | h('html', |
29 | h('head', |
30 | h('title', title), |
31 | ), |
32 | h('body', |
33 | h('div.msg', |
34 | h('p', {innerHTML: '<a href="' + host + '#' + lite + '" rel="nofollow" target="_blank">'+ host + '#' + lite + '</a>'}) |
35 | ) |
36 | ) |
37 | ).outerHTML) |
38 | } |
39 | } |
40 | }).listen(3002) |
41 | } |
42 |
Built with git-ssb-web