Pinggy SDK - v0.1.3
    Preparing search index...

    Function listen

    • Starts an HTTP server (or uses an existing one) and exposes it via a Pinggy tunnel.

      Parameters

      • app: any

        The Express app or http.Server to expose.

      • Optionaloptions: PinggyOptions

        Optional tunnel configuration options.

      Returns Promise<
          Server<typeof IncomingMessage, typeof ServerResponse> & {
              tunnel: TunnelInstance;
          },
      >

      Promise that resolves with the HTTP server instance, with an added tunnel property of type TunnelInstance.

      This function provides a utility to expose an Express app or http.Server via a Pinggy tunnel. It supports both Express applications and native Node.js http.Server instances.

      Error if the input is not an Express app or http.Server, or if tunnel setup fails.

      import express from 'express';
      import { listen } from '@pinggy/pinggy';

      const app = express();
      app.get('/', (req, res) => res.send('Hello World!'));

      const server = await listen(app, { token: 'your-token' });
      console.log('Tunnel URLs:', server.tunnel.urls());