lorpy
Version:
A simple CLI tool that creates a localtunnel with QR code sharing. Makes local development and remote access easy with instant QR code generation and secure tunnel access. Perfect for mobile testing, demos, and webhooks.
24 lines (23 loc) • 697 B
JavaScript
import localtunnel from 'localtunnel';
import qrcode from 'qrcode-terminal';
export async function startLorpy(port) {
if (!port) {
throw new Error('Usage: lorpy <port>');
}
try {
const tunnel = await localtunnel({ port: Number(port) });
const url = tunnel.url;
if (!url) {
throw new Error('Failed to get localtunnel URL.');
}
console.log(`Your localtunnel URL: ${url}`);
qrcode.generate(url, { small: true });
console.log('Localtunnel is running. Press [Ctrl+C] to stop.');
// Keep process alive until user interrupts
await new Promise(() => {});
tunnel.close();
} catch (err) {
console.error(err.message);
process.exit(1);
}
}