-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.ts
66 lines (56 loc) · 1.75 KB
/
app.ts
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
// IntelliBoard - Copyright (C) 2021 Moritz Kaufmann
// A Paintbrush Application, optimized for Whiteboards and Touchscreens (still needs a lot of work),
// written in Node.JS, using the Express Web-Framework.
// Import Express and Path
import * as express from "express";
import * as path from "path";
// Session and Cookie Addons
import * as coookieparser from "cookie-parser";
// Routers
import * as boardRouter from "./routes/board";
import * as indexRouter from "./routes/index";
import * as authRouter from "./routes/authorization";
import * as overviewRouter from "./routes/overview";
// APIs
import {loadLanguage} from "./Backend/languages";
import * as bodyParser from "body-parser";
// Generate Express
var app = express();
// Setup view Engine
app.set('views', path.join(__dirname, 'views'));
app.set('view engine', 'ejs');
// Setup express details
app.use(coookieparser())
app.use(express.json({limit: '150mb'}));
app.use(bodyParser.json({limit: '150mb'}));
app.use(bodyParser.urlencoded({ // to support URL-encoded bodies
limit: '150mb',
extended: true
}));
app.use(express.urlencoded({ extended: false }));
app.use(express.static(path.join(__dirname, 'public')));
app.use(express.static(path.join(__dirname, 'board')));
// Add Routers
app.use(indexRouter);
app.use(boardRouter);
app.use(authRouter);
app.use(overviewRouter);
// 404 Error Page at end of the Router
app.get('*', function(req, res){
// Send 404 Error
var lang = req.acceptsLanguages('de', 'en');
if (lang == "de") {
res.render("error", {
lang: loadLanguage("de_de"),
errorcode: "404",
"title": "home"
});
} else {
res.render("error", {
lang: loadLanguage("en_us"),
errorcode: "404",
"title": "home"
});
}
});
module.exports = app;