New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details
Socket
Book a DemoSign in
Socket

@ind.ie/https-server

Package Overview
Dependencies
Maintainers
1
Versions
15
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@ind.ie/https-server

HTTPS server that uses nodecert

npmnpm
Version
2.0.1
Version published
Weekly downloads
2
-84.62%
Maintainers
1
Weekly downloads
 
Created
Source

https-server

An HTTPS server that uses nodecert.

Installation

npm i -g @ind.ie/https-server

Usage

Commandline

https-server [folder-to-serve] [--port N]

All arguments are optional. By default, a secure HTTP1 server will be created 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 will be 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.

API

https-server provides a createServer method that behaves like the built-in https module’s createServer function so anywhere you use https.createServer, you can simply replace it with httpsServer.createServer. Similarly, there is also a createSecureServer method that mirrors the function in the http2 module.

createServer([options], [requestListener])

  • options (object): see https.createServer. Populates the cert and key properties from the automatically-created nodecert certificates and will overwrite them if they exist in the options object you pass in.

  • requestListener (function): see https.createServer.

  • Returns: https.Server instance, configured with locally-trusted certificates.

Example
const httpsServer = require('https-server')
const express = require('express')

const app = express()
app.use(express.static('.'))

const options = {} // (optional) customise your server
const server = httpsServer.createServer(options, app).listen(443, () => {
  console.log(` 🎉 Serving on https://localhost\n`)
})

createSecureServer([options], [requestListener])

Example
const httpsServer = require('https-server')
const express = require('express')

const options = {} // (optional) customise your server
const server = httpsServer.createSecureServer(options, app).listen(443, () => {
  console.log(` 🎉 Serving on https://localhost (HTTP2)\n`)
})

serve([pathToServe], [callback], [port])

  • pathToServe (string): the directory to serve using Express.static.

  • 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.)

  • Returns: https.Server instance, configured with locally-trusted certificates.

Example
const httpsServer = require('https-server')

// Serve the current directory over https://localhost
const server = httpsServer.serve()

Help wanted

I can use your help to test https-server on other the following platforms:

  • Windows 64-bit (should work without requiring any dependencies)
  • Linux with yum
  • macOS with MacPorts

Please let me know how/if it works. Thank you!

TODO

  • Command-line app. ✔
  • Easy integration with Express, etc. ✔
  • HTTP2 support (API only). ✔
  • To-do: Seamless switch to using ACME/Let’s Encrypt in production.

Thanks

FAQs

Package last updated on 01 Mar 2019

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts