-
Notifications
You must be signed in to change notification settings - Fork 77
/
app.js
39 lines (31 loc) · 902 Bytes
/
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
var express = require('express'),
compression = require('compression'),
bodyParser = require('body-parser'),
pkg = require('./package.json'),
api = require('./api'),
app = express(),
port = Number(process.env.PORT || 5001);
app.use(compression());
app.use(bodyParser.json());
app.use('/', express.static(__dirname + '/static'));
app.get(/^\/\w+\/$/, function(req, res) {
res.sendFile(__dirname + '/static/index.html');
});
app.get(/^\/embed\/\w+\/$/, function(req, res) {
res.sendFile(__dirname + '/static/embed.html');
});
app.get(/^\/\w+$/, function(req, res) {
res.redirect(req.url + '/');
});
app.get(/^\/embed\/\w+$/, function(req, res) {
res.redirect(req.url + '/');
});
api(app);
app.listen(port);
console.log(
'Express version ' +
pkg.dependencies.express.replace(/[^\w\.]/g, '') +
' starting server on port ' +
port +
'.'
);