-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathserver.js
More file actions
33 lines (26 loc) · 1.04 KB
/
server.js
File metadata and controls
33 lines (26 loc) · 1.04 KB
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
var express = require('express');
var rewrite = require('express-urlrewrite');
var https = require('https');
var fs = require('fs');
var path = require('path');
var privateKey = fs.readFileSync(__dirname + '/cert/key.pfx', 'ascii');
var certificate = fs.readFileSync(__dirname +'/cert/cert.pem', 'ascii');
var credentials = {key: privateKey, cert: certificate};
var app = express();
/*
fs.readdirSync(__dirname).forEach(function (file) {
if (fs.statSync(path.join(__dirname, file)).isDirectory()) {
app.use(rewrite('/' + file + '/*', '/' + file + '/index.html'));
}
});*/
app.use('/', express.static(__dirname));
app.use(rewrite('index.html'));
app.use('/scritps', express.static(__dirname + '/scripts'));
app.use('/resources', express.static(__dirname + '/resources'));
var httpsServer = https.createServer(credentials, app);
// set the port of our application
// process.env.PORT lets the port be set by Heroku
var port = process.env.PORT || 8080;
app.listen(port);
httpsServer.listen(4443);
console.log("Express server listening on port " + port );