Created
October 19, 2019 02:09
-
-
Save angellandros/a916a233cd9288f38d7d85afddc39eb2 to your computer and use it in GitHub Desktop.
Sample Express.js TypeScript app with HTTPS
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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