Package Exports
- pipenet
- pipenet/server
Readme
pipenet
pipenet exposes your localhost to the world for easy testing and sharing! No need to mess with DNS or deploy just to have others test out your changes.
Installation
npm install pipenet
# or
pnpm add pipenetAPI
The pipenet client is also usable through an API (for test integration, automation, etc)
pipenet(port [,options][,callback])
Creates a new pipenet tunnel to the specified local port. Will return a Promise that resolves once you have been assigned a public tunnel url. options can be used to request a specific subdomain. A callback function can be passed, in which case it won't return a Promise. This exists for backwards compatibility with the old Node-style callback API. You may also pass a single options object with port as a property.
import pipenet from 'pipenet';
const tunnel = await pipenet({ port: 3000 });
// the assigned public url for your tunnel
// i.e. https://abcdefgjhij.pipenet.me
tunnel.url;
tunnel.on('close', () => {
// tunnels are closed
});options
port(number) [required] The local port number to expose through pipenet.subdomain(string) Request a specific subdomain on the proxy server. Note You may not actually receive this name depending on availability.host(string) URL for the upstream proxy server. Defaults tohttps://pipenet.me.local_host(string) Proxy to this hostname instead oflocalhost. This will also cause theHostheader to be re-written to this value in proxied requests.local_https(boolean) Enable tunneling to local HTTPS server.local_cert(string) Path to certificate PEM file for local HTTPS server.local_key(string) Path to certificate key file for local HTTPS server.local_ca(string) Path to certificate authority file for self-signed certificates.allow_invalid_cert(boolean) Disable certificate checks for your local HTTPS server (ignore cert/key/ca options).
Refer to tls.createSecureContext for details on the certificate options.
Tunnel
The tunnel instance returned to your callback emits the following events
| event | args | description |
|---|---|---|
| request | info | fires when a request is processed by the tunnel, contains method and path fields |
| error | err | fires when an error happens on the tunnel |
| close | fires when the tunnel has closed |
The tunnel instance has the following methods
| method | args | description |
|---|---|---|
| close | close the tunnel |
Server
This package includes both the client and server components. You can run your own pipenet server.
Running the Server
# Using the CLI
npx pipenet-server --port 3000
# Or programmaticallyimport { createServer } from 'pipenet/server';
const server = createServer({
domain: 'tunnel.example.com', // Optional: custom domain
secure: false, // Optional: require HTTPS
landing: 'https://example.com', // Optional: landing page URL
max_tcp_sockets: 10, // Optional: max sockets per client
});
server.listen(3000, () => {
console.log('pipenet server listening on port 3000');
});Server Options
domain(string) Custom domain for the tunnel serversecure(boolean) Require HTTPS connectionslanding(string) URL to redirect root requests tomax_tcp_sockets(number) Maximum number of TCP sockets per client (default: 10)
Server API Endpoints
GET /api/status- Server status and tunnel countGET /api/tunnels/:id/status- Status of a specific tunnelGET /:id- Request a new tunnel with the specified ID
Acknowledgments
pipenet is based on localtunnel, an open-source project by @defunctzombie. We are grateful for the foundation it provided.
Development of pipenet is sponsored by glama.ai.
License
MIT