HttpsServer
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.
The simple mental model
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 pattern explains the named API. Application classes, credentials, and assets may need to be supplied; use a complete recipe for a runnable starting point.
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.
Choices you can make
- 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.