Skip to content

Commit

Permalink
Add SSL HTTPS support to server.js
Browse files Browse the repository at this point in the history
  • Loading branch information
levi committed Apr 5, 2013
1 parent a883329 commit da3e770
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
2 changes: 2 additions & 0 deletions config.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ module.exports = {
"port": 41234,
"clientAddress": "",
"privateAddress": "",
"sslKey": "",
"sslCert": "",
"baudrate": 9600,
"serialDevice": "/dev/tty.usbmodemfa131"
};
14 changes: 11 additions & 3 deletions server.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,16 @@
var config = require('./config');
var config = require('./config'),
fs = require('fs');

var express = require('express'),
https = require('https'),
http = require('http'),
app = express();

var options = {
key: fs.readFileSync(config.sslKey),
cert: fs.readFIleSync(config.sslCert),
};

var dgram = require('dgram'),
client = dgram.createSocket("udp4");

Expand All @@ -18,5 +24,7 @@ app.get('/purchase.js', function(req, res) {
res.send(200);
});

app.listen(3000)
console.log('Listening on port 3000');
http.createServer(app).listen(3000);
https.createServer(options, app).listen(3001);

console.log('Listening on port 3000 and 3001 (ssl)');

0 comments on commit da3e770

Please sign in to comment.