@stephen-shopopop/node-metrics
    Preparing search index...

    Function createWebServer

    • Creates and starts an HTTP web server on the specified port.

      Parameters

      • options: WebServerOptions

        The configuration options for the web server.

        Configuration options for the web server.

        • fetchCallback: FetchCallback

          A callback function to handle fetch requests.

        • Optionalport?: number

          The port number on which the server will listen. Defaults to 0 if not specified.

      Returns Promise<{ address: AddressInfo; server: Server }>

      A promise that resolves to an object containing the created server instance and its address information.

      const { server } = await createWebServer({
      port: 9000,
      fetchCallback: (ctx) => {
      if (ctx.method === 'GET' && ctx.path('/')) {
      return new Response('OK');
      }

      return new Response();
      }
      });