nx.js
Functions

listen

listen(opts): Server

Creates an HTTP server and listens on the port number specified in the options object. The fetch function will be invoked upon receiving an HTTP request.

Parameters

ParameterType
optsListenOptions

Returns

Server

Example

import { listen } from '@nx.js/http';
 
listen({
  port: 8080,
  fetch(req) {
    console.log(`Got HTTP ${req.method} request for "${req.url}"`);
    return new Response('Hello World!');
  }
});

On this page