Skip to content

Commit 12c125e

Browse files
committed
Merge pull request #21 from joeybaker/patch-1
Enable an https lr server
2 parents b28152d + 68db18b commit 12c125e

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)