-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstep2.js
More file actions
27 lines (23 loc) · 850 Bytes
/
step2.js
File metadata and controls
27 lines (23 loc) · 850 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
// Load a couple built-in node libraries
var HTTPS = require('https');
var FS = require('fs');
// Load a couple third-party node modules
var Stack = require('stack');
var Creationix = require('creationix');
// Serve files relative to the current working directory
var root = process.cwd();
// Listen on the alt-https port
var port = process.env.PORT || 8433;
// Load our self-signed cert for HTTPS support
var options = {
key: FS.readFileSync(__dirname + '/keys/nodebits-key.pem'),
cert: FS.readFileSync(__dirname + '/keys/nodebits-cert.pem')
};
// Stack up a server and start listening
HTTPS.createServer(options, Stack(
Creationix.log(),
Creationix.indexer("/", root),
Creationix.static("/", root)
)).listen(port);
// Give the user a nice message on the standard output
console.log("Serving %s at https://localhost:%s/", root, port);