-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.js
executable file
·76 lines (70 loc) · 2.15 KB
/
app.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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
'use strict';
var express = require('express'),
fs = require('fs'),
http = require('http'),
https = require('https'),
path = require('path'),
siteUrl = "https://lug.utdallas.edu",
certPath = "/var/www/certs/",
options = {
key: fs.readFileSync(certPath + 'lug.utdallas.edu.key'),
cert: fs.readFileSync(certPath + 'lug.utdallas.edu.cert.cer'),
ca: [
fs.readFileSync(certPath + 'root.cer'),
fs.readFileSync(certPath + 'inter1.cer')
]
},
app = express(),
appRedirect = express();
app.set('views', __dirname + '/views');
app.set('port', process.env.PORT || 3001); // dev
app.set('view engine', 'jade');
app.use(app.router);
app.use(express.static(path.join(__dirname, 'public')));
app.use(express.logger('dev'));
app.use(express.bodyParser());
app.use(express.methodOverride());
app.use(function(err, req, res, next) {
var code = err.code,
message = err.message;
res.writeHead(code, message, {
'content-type': 'text/plain'
});
res.end(message);
});
app.use(function(req, res, next) {
res.status(404);
res.redirect(siteUrl);
});
if ('development' == app.get('env')) {
app.use(express.errorHandler());
}
appRedirect.set('port', 3002);
appRedirect.get("*", function(req, res) {
res.redirect(siteUrl + req.path);
});
app.get('/', function(req, res) {
res.render('index', {
title: "Linux Users Group @ UTD"
});
});
app.get('/join', function(req, res) {
res.redirect("https://orgsync.com/join/15316/linux-users-group");
});
app.get('/chat', function(req, res) {
res.redirect("https://scrollback.io/lug-utd");
});
app.get('/irc', function(req, res) {
res.redirect(siteUrl + ":3000");
});
app.get('/about', function(req, res) {
res.render('about', {
title: "Linux Users Group @ UTD"
});
});
http.createServer(appRedirect).listen(appRedirect.get('port'), function() {
console.log('Express server (http redirect) listening on port ' + appRedirect.get('port'));
});
https.createServer(options, app).listen(app.get('port'), function() {
console.log('Express server (SSL) listening on port ' + app.get('port'));
});