svrx-plugin-localtunnel
Advanced tools
Comparing version 0.0.1 to 1.0.0
57
index.js
@@ -1,2 +0,1 @@ | ||
const localtunnel = require('localtunnel'); | ||
@@ -7,41 +6,53 @@ | ||
configSchema: { | ||
subdomain: { | ||
type: 'string', | ||
description: | ||
'A string value requesting a specific subdomain on the proxy server', | ||
'A string value requesting a specific subdomain on the proxy server' | ||
}, | ||
localhost: { | ||
type: 'string', | ||
description: 'Proxy to this hostname instead of localhost', | ||
description: 'Proxy to this hostname instead of localhost' | ||
}, | ||
host: { | ||
type: 'string', | ||
description: 'use your own localtunnel server, defualt is "https://localtunnel.me"', | ||
}, | ||
description: | ||
'use your own localtunnel server, defualt is "https://localtunnel.me"' | ||
} | ||
}, | ||
hooks: { | ||
async onCreate({ io, config, events, logger }) { | ||
async onCreate({ config, events, logger }) { | ||
let tunnel; | ||
events.on('ready', ()=>{ | ||
events.on('ready', () => { | ||
const stopSpin = logger.spin('connecting to localtunnel...'); | ||
const port = config.get('$.port'); | ||
tunnel = localtunnel(port, { | ||
host: config.get('host'), | ||
local_host: config.get('localhost'), | ||
subdomain: config.get('subdomain'), | ||
}, (err, tunnel)=>{ | ||
if(err) logger.error(`localtunnel setup failed, beacuse {err.stack || err.message}`) | ||
logger.notify(`url is available on ${tunnel.url}`) | ||
}) | ||
tunnel.on('error', (err)=>{ | ||
logger.error(err.message) | ||
}) | ||
}) | ||
const { chalk } = logger; | ||
tunnel = localtunnel( | ||
port, | ||
{ | ||
host: config.get('host'), | ||
local_host: config.get('localhost'), | ||
subdomain: config.get('subdomain') | ||
}, | ||
(err, tunnel) => { | ||
stopSpin(); | ||
if (err) | ||
logger.error( | ||
`localtunnel setup failed, beacuse {err.stack || err.message}` | ||
); | ||
logger.notify( | ||
`url is available at ${chalk.underline.blue(tunnel.url)}` | ||
); | ||
} | ||
); | ||
tunnel.on('error', err => { | ||
logger.error(err.message); | ||
}); | ||
}); | ||
// onCreate | ||
return () => { | ||
if(tunnel) tunnel.close(); | ||
} | ||
if (tunnel) tunnel.close(); | ||
}; | ||
} | ||
} | ||
}; | ||
}; |
{ | ||
"name": "svrx-plugin-localtunnel", | ||
"version": "0.0.1", | ||
"version": "1.0.0", | ||
"description": "localtunnel plugin for server-x", | ||
@@ -8,3 +8,3 @@ "main": "index.js", | ||
"engines": { | ||
"svrx": "~0.0" | ||
"svrx": "^1.0.0" | ||
}, | ||
@@ -11,0 +11,0 @@ "keywords": [ |
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
3033
55
1