const https = require("https"); const fs = require("fs"); const express = require("express"); // read keys const key = fs.readFileSync("localhost.key"); const cert = fs.readFileSync("localhost.crt"); // create express app const app = express(); // create a HTTPS server const server = https.createServer({ key, cert }, app); // add test route app.get("/", (req, res) => { res.send("this is an secure server"); }); // start server on port 8000 server.listen(8000, () => { console.log("listening on 8000"); });