http-server-plus

raw JSON →
1.0.0 verified Sat Apr 25 auth: no javascript

An augmented Node.js HTTP server that supports HTTP, HTTPS, and HTTP/2 on the same instance, with the ability to listen on multiple ports, sockets, or file descriptors simultaneously. Version 1.0.0 is stable with irregular release cadence. Key differentiators include unified server creation via `create()`, promise-based `.listen()` with nice addresses, and built-in support for HTTP/2 via `http2` (Node >=8) or `spdy` (Node <8). Suitable for advanced server setups needing multiple protocols or endpoints.

error TypeError: Cannot read property 'create' of undefined
cause Incorrect import of default export when expecting named export in CommonJS.
fix
Use const { create } = require('http-server-plus');
error Error: The server could not listen on ...
cause Hostname or port already in use, missing certificates, or invalid socket path.
fix
Check error.niceAddress for details; ensure ports are free, certificates exist, and sockets paths are valid.
breaking listen() now returns a Promise instead of the server object
fix Use async/await or .then() to handle the Promise returned by listen().
deprecated Support for spdy (HTTP/2 for Node <8) is deprecated, use built-in http2 module
fix For Node >=8, use http2.createSecureServer as shown in docs.
gotcha When calling listen() with multiple options, the Promise returned from each listen() must be awaited
fix Use Promise.all() to await all listen() calls as shown in the example.
npm install http-server-plus
yarn add http-server-plus
pnpm add http-server-plus

Shows creating a server with Express request handler, listening on two ports concurrently using async/await.

import { create } from 'http-server-plus';
import express from 'express';

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

const server = create(app);

(async () => {
  try {
    const addresses = await Promise.all([
      server.listen({ hostname: 'localhost', port: 3000 }),
      server.listen({ hostname: 'localhost', port: 3001 })
    ]);
    console.log('Server listening on:', addresses);
  } catch (err) {
    console.error('Failed to start:', err);
  }
})();