Skip to content

Instantly share code, notes, and snippets.

@angellandros
Created October 19, 2019 02:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save angellandros/a916a233cd9288f38d7d85afddc39eb2 to your computer and use it in GitHub Desktop.
Save angellandros/a916a233cd9288f38d7d85afddc39eb2 to your computer and use it in GitHub Desktop.
Sample Express.js TypeScript app with HTTPS
import * as express from 'express';
import * as fs from 'fs';
import * as https from 'https';
import { RegisterRoutes } from './routes/routes';
const privateKey = fs.readFileSync('cert/cert.key');
const certificate = fs.readFileSync('cert/cert.crt');
const credentials = {key: privateKey, cert: certificate};
const app = express();
const port = 3000;
RegisterRoutes(app);
const httpsServer = https.createServer(credentials, app);
httpsServer.listen(port, () => console.log(`Server started listening to port ${port}`));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment