Created
October 21, 2014 00:59
-
-
Save nvcexploder/15d71efb16f926771e73 to your computer and use it in GitHub Desktop.
Creating a TLS server in hapi.js
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
var Hapi = require('hapi'); | |
var Fs = require('fs'); | |
var options = { | |
tls: { | |
key: Fs.readFileSync(your_key), | |
cert: Fs.readFileSync(your_cert) | |
} | |
}; | |
var server = Hapi.createServer('localhost', 4433, options); | |
server.route({ | |
path: '/', | |
method: 'GET', | |
handler: function (request, reply) { | |
reply({ name: 'Simon Skinner', occupation: 'Slasher of Prices' }); | |
} | |
}); | |
server.start( function () { | |
console.log('The Greater Good.'); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment