-
Notifications
You must be signed in to change notification settings - Fork 0
/
server.js
42 lines (32 loc) · 1.01 KB
/
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
console.time("Started in");
var express = require('express');
var compression = require('compression');
var bodyParser = require("body-parser");
var controller = require("./modules/controller");
var favicon = require('serve-favicon');
var app = express();
app.use(compression());
app.use(express.static('./public'));
app.use(express.static('../ElaiJS'));
app.use(favicon(__dirname + '/public/images/favicon.png'));
app.use(bodyParser.urlencoded({ extended: true }));
app.use(bodyParser.json());
app.post('/rest/:name', controller());
app.get("*.js", ressourcesNotFound);
app.get("*.css", ressourcesNotFound);
app.get("*.png", ressourcesNotFound);
app.get("*.json", ressourcesNotFound);
app.get("*.properties", ressourcesNotFound);
app.get("*.gif", ressourcesNotFound);
function ressourcesNotFound(req, res) {
res.writeHead(404);
res.end();
}
app.get("*", function(req, res) {
res.writeHead(301, {
'Location': '/#404'
});
res.end();
});
app.listen(8080);
console.timeEnd("Started in");