-
Notifications
You must be signed in to change notification settings - Fork 9
/
static-server.js
145 lines (110 loc) · 3.51 KB
/
static-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
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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
var express = require('express');
var app = express();
app.set('port', (process.env.PORT || 7069));
var pageData = {
"devMode": true,
"javascriptsBase": "/javascripts",
"stylesheetsBase": "/stylesheets",
"imagesBase": "/images",
"applicationName": "Stonecutter",
"serviceName": "Objective8",
"demoAppURL": "http://localhost:7778"
};
app.use('/', express.static(__dirname + '/resources/public'));
app.set('view engine', 'jade');
app.set('views', './assets/jade');
function beforeAllFilter(req, res, next) {
app.locals.pretty = true;
next();
}
app.all('*', beforeAllFilter);
function customRender(res, template, data) {
res.render(template, data, function (err, html) {
var cleanHTML = html.replace(/>!/g, '>');
res.send(cleanHTML);
});
}
app.get('/', function (req, res) {
customRender(res, 'index', pageData);
});
app.get('/library', function (req, res) {
customRender(res, 'library', pageData);
});
app.all('/routes', function (req, res) {
customRender(res, 'routes', pageData);
});
app.all('/change-password', function (req, res) {
customRender(res, 'change-password', pageData);
});
app.all('/change-email', function (req, res) {
customRender(res, 'change-email', pageData);
});
app.all('/change-profile', function (req, res) {
customRender(res, 'change-profile', pageData);
});
app.all('/confirmation-sign-in', function (req, res) {
customRender(res, 'confirmation-sign-in', pageData);
});
app.all('/profile-created', function (req, res) {
customRender(res, 'profile-created', pageData);
});
app.all('/profile-deleted', function (req, res) {
customRender(res, 'profile-deleted', pageData);
});
app.all('/authorise', function (req, res) {
customRender(res, 'authorise', pageData);
});
app.all('/authorise-failure', function (req, res) {
customRender(res, 'authorise-failure', pageData);
});
app.get('/forgot-password', function (req, res) {
customRender(res, 'forgot-password', pageData);
});
app.get('/forgot-password-confirmation', function (req, res) {
customRender(res, 'forgot-password-confirmation', pageData);
});
app.get('/reset-password', function(req, res) {
customRender(res, 'reset-password', pageData)
});
app.all('/profile', function (req, res) {
customRender(res, 'profile', pageData);
});
app.all('/unshare-profile-card', function (req, res) {
customRender(res, 'unshare-profile-card', pageData);
});
app.all('/confirm-email-expired', function (req, res) {
customRender(res, 'confirm-email-expired', pageData);
});
app.all('/confirm-email-resent', function (req, res) {
customRender(res, 'confirm-email-resent', pageData);
});
app.get('/delete-account', function (req, res) {
customRender(res, 'delete-account', pageData);
});
app.get('/error-404', function (req, res) {
customRender(res, 'error-404', pageData);
});
app.get('/error-500', function (req, res) {
customRender(res, 'error-500', pageData);
});
app.get('/sign-out', function (req, res) {
res.redirect('/');
});
app.get('/admin/sign-in', function (req, res) {
customRender(res, 'admin-sign-in', pageData);
});
app.all('/admin/user-list', function (req, res) {
customRender(res, 'user-list', pageData);
});
app.get('/admin/invite', function (req, res) {
customRender(res, 'admin-invite-user', pageData);
});
app.get('/admin/apps', function (req, res) {
customRender(res, 'admin-apps', pageData);
});
app.get('/email-demo', function (req, res) {
customRender(res, 'email-demo', pageData);
});
app.listen(app.get('port'), function () {
console.log('Node app is running on port', app.get('port'));
});