HTTPS support, Promise API, modern ES syntax

* Add support for tunneling a local HTTPS server.
* Return a Promise from localtunnel.
This commit is contained in:
Gert Hengeveld
2019-09-16 16:30:13 +02:00
committed by Roman Shtylman
parent d7330a7121
commit 2a74d6be9f
16 changed files with 719 additions and 663 deletions

14
localtunnel.js Normal file
View File

@@ -0,0 +1,14 @@
const Tunnel = require('./lib/Tunnel');
module.exports = function localtunnel(arg1, arg2, arg3) {
const options = typeof arg1 === 'object' ? arg1 : { ...arg2, port: arg1 };
const callback = typeof arg1 === 'object' ? arg2 : arg3;
const client = new Tunnel(options);
if (callback) {
client.open(err => (err ? callback(err) : callback(null, client)));
return client;
}
return new Promise((resolve, reject) =>
client.open(err => (err ? reject(err) : resolve(client)))
);
};