Verified Commit 628c9950 authored by Aral Balkan's avatar Aral Balkan
Browse files

Add deprecation warnings

  - is now
parent 43c5081f
# HTTPS Server
HTTPS Server is a secure [Small Tech]( personal web server for seamless development and live use.
## WARNING: This module has been deprecated, do not use.
HTTP Server uses [nodecert]( for seamless locally-trusted TLS certificate provisioning and use during development and [ACME TLS]( for seamless globally-trusted [Let’s Encrypt]( TLS certificate provisioning and use on live environments.
HTTPS Server has been renamed to [Indie Web Server]( and moved to the []( npm module.
__Please install the latest version of Indie Web Server instead of using this module.__
## Install
## Migration instructions
npm i -g
1. Remove https-server from global npm packages:
## Use
npm uninstall -g
### Command-line
2. Remove https-server from your local (if you were using the API):
Start serving the current directory at https://localhost:
npm uninstall
$ https-server
3. Install Indie Web Server as a global npm package and use the `web-server` command in Terminal:
Start serving the _site_ directory at your hostname:
npm i -g
4. Install Indie Web Server into your project to use the API:
$ https-server site --global
npm i
And in your app:
const webServer = require('')
For example, if you run the command on a connected server that has the domain pointing to it and `` set in _/etc/hostname_ (on Unix/Linux), you will be able to access the site at The first time you access it, it will take a little longer to load as your Let’s Encrypt certificates are being automatically provisioned.
#### Syntax
https-server [folder-to-serve] [--port N] [--global] [--version]
All command-line arguments are optional. By default, an HTTPS server with locally-trusted certificates will be created for you to serve the current folder over port 443.
If you do not already have TLS certificates, they will be created for you automatically using [nodecert](
All dependencies are installed automatically for you if they do not exist if you have apt, pacman, or yum (untested) on Linux or if you have [Homebrew]( or [MacPorts]( (untested) on macOS.
If you specify the `--global` flag, globally-trusted Let’s Encrypt TLS certificates are automatically provisioned for you using ACME-TLS the first time you hit your hostname. The hostname for the certificates is automatically set from the hostname of your system (and the _www._ subdomain is also automatically provisioned).
### API
HTTPS Server’s `createServer` method behaves like the built-in _https_ module’s `createServer` function. Anywhere you use `https.createServer`, you can simply replace it with `httpsServer.createServer`.
#### createServer([options], [requestListener])
- __options__ _(object)___:__ see [https.createServer]( Populates the `cert` and `key` properties from the automatically-created [nodecert]( or Let’s Encrypt certificates and will overwrite them if they exist in the options object you pass in. If your options has ` = true` set, globally-trusted TLS certificates are obtained from Let’s Encrypt using ACME TLS.
- __requestListener__ _(function)___:__ see [https.createServer]( If you don’t pass a request listener, HTTPS Server will use its default one.
__Returns:__ [https.Server]( instance, configured with either locally-trusted certificates via nodecert or globally-trusted ones from Let’s Encrypt.
##### Example
const httpsServer = require('https-server')
const express = require('express')
const app = express()
const options = {} // to use globally-trusted certificates instead, set this to {global: true}
const server = httpsServer.createServer(options, app).listen(443, () => {
console.log(` 🎉 Serving on https://localhost\n`)
#### serve([options])
Options is an optional parameter object that may contain the following properties, all optional:
- __path__ _(string)___:__ the directory to serve using [Express](
- __callback__ _(function)___:__ a function to be called when the server is ready. If you do not specify a callback, you can specify the port as the second argument.
- __port__ _(number)___:__ the port to serve on. Defaults to 443. (On Linux, privileges to bind to the port are automatically obtained for you.)
- __global__ _(boolean)___:__ if true, globally-trusted Let’s Encrypt certificates will be provisioned (if necesary) and used via ACME TLS. If false (default), locally-trusted certificates will be provisioned (if necesary) and used using nodecert.
__Returns:__ [https.Server]( instance, configured with either locally or globally-trusted certificates.
##### Example
Using locally-trusted TLS certificates:
const httpsServer = require('https-server')
// Serve the current directory over https://localhost
const server = httpsServer.serve()
Using globally-trusted TLS certificates:
const httpsServer = require('https-server')
// Serve the current directory over https://localhost
const server = httpsServer.serve({global: true})
## Help wanted
I can use your help to test HTTPS Server on the following platform/package manager combinations:
- Linux with yum
- macOS with MacPorts
Please [let me know how/if it works]( Thank you!
Also, automatic hostname detection has not been implemented for Windows and so globally-trusted certificates will fail on that platform. If you get to it before I do, [I would appreciate a pull request](
## Thanks
* [thagoat]( for confirming that [installation works on Arch Linux with Pacman](
* [Tim Knip]( for confirming that [the module works with 64-bit Windows]( with the following behaviour: “Install pops up a windows dialog to allow adding the cert.”
* [Run Rabbit Run]( for [the following information]( on 64-bit Windows: “Win64: works with the windows cert install popup on server launch. Chrome and ie are ok with the site then. FF 65 still throws the cert warning even after restarting.”
For for further instructions, please see the [Indie Web Server documentation]( project.
\ No newline at end of file
......@@ -4,6 +4,11 @@ const path = require('path')
var ansi = require('ansi-escape-sequences')
const httpsServer = require('../index.js')
function displayDeprecationWarning() {
const deprecationNotice = `\n${clr(' WARNING: This module is deprecated. Do not use.', ['red', 'bg-white'])}\n${clr(httpsServer.deprecationNotice(), 'yellow')}`
const arguments = require('minimist')(process.argv.slice(2))
if (arguments._.length > 2 || === true) {
......@@ -24,12 +29,16 @@ if (arguments._.length > 2 || === true) {
${usageVersionOption}\t\t\tDisplay the version.
`.replace(/\n$/, '').replace(/^\n/, '')
if (arguments.version !== undefined) {
const version = JSON.parse(fs.readFileSync(path.join(__dirname, '../package.json'), 'utf-8')).version
console.log(` https-server v${version}\n`)
......@@ -54,10 +63,14 @@ if ( !== undefined) {
if (!fs.existsSync(pathToServe)) {
console.log(` 🤔 Error: could not find path ${pathToServe}\n`)
// Start the server.
path: pathToServe,
......@@ -43,17 +43,24 @@ class HttpsServer {
serve (options) {
// The options parameter object and all supported properties on the options parameter
// object are optional. Check and populate the defaults.
const self = this
if (options === undefined) options = {}
const pathToServe = typeof options.path === 'string' ? options.path : '.'
const port = typeof options.port === 'number' ? options.port : 443
const global = typeof === 'boolean' ? : false
const callback = typeof options.callback === 'function' ? options.callback : function () {
// Callback.
const serverPort = this.address().port
let portSuffix = ''
if (serverPort !== 443) {
portSuffix = `:${serverPort}`
const location = global ? os.hostname() : `localhost${portSuffix}`
console.log(` 🎉 Serving ${pathToServe} on https://${location}\n`)
......@@ -85,6 +92,17 @@ class HttpsServer {
return server
// This module is deprecated. It has been moved to
deprecationNotice () {
return '\nHTTPS Server has been renamed to Indie Web Server and moved to Please install the latest version of Indie Web Server instead of using this module.\n'
displayDeprecationWarning() {
const deprecationWarning = `\nWARNING: THIS MODULE IS DEPRECATED – DO NOT USE.\n${this.deprecationNotice()}`
// Private.
"name": "",
"version": "5.1.0",
"description": "A secure Small Tech personal web server for seamless development and live use.",
"version": "5.1.1",
"description": "Deprecated, please use instead.",
"main": "index.js",
"bin": "bin/https-server.js",
"scripts": {
......@@ -10,7 +10,7 @@
"repository": {
"type": "git",
"url": ""
"url": ""
"author": {
"name": "Aral Balkan",
......@@ -5,6 +5,7 @@ const https = require('https')
const indexHTML = "<!DOCTYPE html><html lang='en'><head><title>Test</title><body><h1>Test</h1></body></html>"
async function secureGet (url) {
return new Promise((resolve, reject) => {
......@@ -25,6 +26,9 @@ async function secureGet (url) {
test('create https server', t => {
const server = httpsServer.createServer()
t.ok(server instanceof https.Server, 'is https.Server')
......@@ -38,6 +42,9 @@ test('create https server', t => {
test('static serve https', t => {
const server = httpsServer.serve({path: 'test/site', callback: async () => {
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment