Skip to content

Commit

Permalink
feat(express): implement SSL support
Browse files Browse the repository at this point in the history
SSL support is now implemented independently of webpack dev server
  • Loading branch information
dmbch committed Feb 19, 2018
1 parent 6ec751b commit ec0026c
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 1 deletion.
20 changes: 19 additions & 1 deletion packages/express/lib/utils.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
'use strict';

var fs = require('fs');
var url = require('url');
var path = require('path');
var http = require('http');
var https = require('https');

var hopsConfig = require('hops-config');

Expand All @@ -22,7 +26,21 @@ function defaultCallback(error) {
}

exports.run = function run(app, callback) {
var server = app.listen(hopsConfig.port, hopsConfig.host, function(error) {
var server;
if (hopsConfig.https) {
var options = {
key: fs.readFileSync(
hopsConfig.keyFile || path.join(__dirname, 'ssl', 'localhost.ssl.key')
),
cert: fs.readFileSync(
hopsConfig.certFile || path.join(__dirname, 'ssl', 'localhost.ssl.crt')
),
};
server = https.createServer(options, app);
} else {
server = http.createServer(app);
}
server.listen(hopsConfig.port, hopsConfig.host, function(error) {
(callback || defaultCallback)(error, server);
});
};
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 comments on commit ec0026c

Please sign in to comment.