-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathindex.js
41 lines (33 loc) · 900 Bytes
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
var Server = require('alexa-app-server');
var localtunnel = require('localtunnel');
var defaults = {
port: process.env.port || 80,
onTunnelStart: function (tunnel) {
console.log('Tunnel URL: %s', tunnel.url);
},
onTunnelError: function (err) {
console.error('Tunnel Error: %s', err.message);
}
};
function HomeServer (serverConfig) {
var config = Object.assign({}, defaults, serverConfig);
this.start = function () {
localtunnel(config.port, {
subdomain: config.subdomain,
local_host: config.localhost
}, function (err, info) {
if (err) {
config.onTunnelError(err);
} else {
config.onTunnelStart(info);
}
});
return new Server(config).start();
};
}
HomeServer.start = function (config) {
var homeServer = new HomeServer(config);
homeServer.start();
return homeServer;
};
module.exports = HomeServer;