-
Notifications
You must be signed in to change notification settings - Fork 2
/
server.js
38 lines (33 loc) · 1013 Bytes
/
server.js
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
28
29
30
31
32
33
34
35
36
37
38
// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.
// See LICENSE in the project root for license information.
var express = require('express');
var serveStatic = require('serve-static');
var argv = require('optimist')
.boolean(['ssl', 'ngrok'])
.argv;
var app = express();
app.use(serveStatic(__dirname + '/public'));
if (argv.ssl) {
var https = require('https');
var fs = require('fs');
var port = 3443;
var server = https.createServer({
key: fs.readFileSync('key.pem'),
cert: fs.readFileSync('cert.pem')
}, app);
server.listen(port, function () {
console.log('Listening on https://localhost:' + port);
});
} else {
var port = process.env.port || 3000;
app.listen(port, function () {
if (argv.ngrok) {
var ngrok = require('ngrok');
ngrok.connect(port, function (err, url) {
console.log('Listening on ' + url);
});
} else {
console.log('Listening on http://localhost:' + port);
}
});
}