Skip to content

Commit 68db18b

Browse files
committed
Enable an https lr server
By passing the contents of cert files, we can enable an https version of the lr server which is super handy for debugging https.
1 parent 3f220b6 commit 68db18b

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

lib/server.js

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
21
var fs = require('fs');
32
var qs = require('qs');
43
var path = require('path');
54
var util = require('util');
65
var http = require('http');
6+
var https = require('https');
77
var events = require('events');
88
var parse = require('url').parse;
99
var debug = require('debug')('tinylr:server');
@@ -12,8 +12,6 @@ var constants = require('constants');
1212

1313
var config = require('../package.json');
1414

15-
module.exports = Server;
16-
1715
function Server(options) {
1816
options = this.options = options || {};
1917
events.EventEmitter.call(this);
@@ -32,13 +30,20 @@ function Server(options) {
3230
this.configure(options.app);
3331
}
3432

33+
module.exports = Server;
34+
3535
util.inherits(Server, events.EventEmitter);
3636

3737
Server.prototype.configure = function configure(app) {
3838
debug('Configuring %s', app ? 'connect / express application' : 'HTTP server');
3939

4040
if(!app) {
41-
this.server = http.createServer(this.handler.bind(this));
41+
if (this.options.key && this.options.cert) {
42+
this.server = https.createServer(this.options, this.handler.bind(this));
43+
}
44+
else {
45+
this.server = http.createServer(this.handler.bind(this));
46+
}
4247
this.server.on('upgrade', this.websocketify.bind(this));
4348
this.server.on('error', this.error.bind(this));
4449
return this;

0 commit comments

Comments
 (0)