HttpsServer

Documentation for Redweb 0.13.3. Install that exact version when following these examples.

TLS-enabled variant of HttpServer. Accepts ssl.key and ssl.cert file paths, wraps them in an https server, and bootstraps the same middleware pipeline.

Explain it like I’m five

HttpsServer is HttpServer with a locked, encrypted front door. It reads your certificate and key, then serves the same Express application through TLS.

When should I use it?

Use it when the Node process terminates TLS itself instead of sitting behind a reverse proxy or managed load balancer.

Follow the example

This API pattern illustrates the named surface; it may require application-owned classes, credentials, or assets. Start from a complete recipe for a runnable application.

js
const { HttpsServer, METHODS } = require('redweb')

new HttpsServer({
  port: 4443,
  ssl: { key: './certs/dev.key', cert: './certs/dev.crt' },
  services: [
    { serviceName: '/secure', method: METHODS.GET, function: (req, res) => res.json({ ok: true }) },
  ],
})
  1. The key and certificate files are loaded before the listener starts.
  2. The standard HTTP middleware and services are attached to the Express app.
  3. The resulting HTTPS server binds on the configured port and handles encrypted requests.

Options

  • All HttpServer options
  • ssl.key: path to private key (required)
  • ssl.cert: path to certificate (required)

Methods and members

constructor(options)

Loads the provided key/cert pair, builds the Express app with BaseHttpServer, then creates and starts the HTTPS listener unless listen is false.

What should I watch for?

Certificate rotation, filesystem permissions, and secure protocol policy remain deployment concerns. Behind a TLS-terminating proxy, HttpServer is usually simpler.