forked from maiuswong/simaware-express
-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.js
69 lines (55 loc) · 1.62 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
// Load libraries
const express = require('express');
const app = express();
const path = require('path');
const exphbs = require('express-handlebars');
const { Sequelize, Model, DataTypes } = require('sequelize');
const minify = require('express-minify');
// Init middleware
app.engine('handlebars', exphbs({defaultLayout: 'main'}));
app.set('view engine', 'handlebars');
const PORT = process.env.PORT || 5001;
// Include the public folder as static
// app.use(minify());
app.use(express.static(path.join(__dirname, 'public')));
/* Index Page */
app.get('/', (req, res) => {
res.render('index');
});
/* Index Page */
app.get('/stats/', (req, res) => {
res.render('stats');
});
/* Airport Page */
app.get('/airport/:icao', (req, res) => {
res.render('airport', { icao: req.params.icao });
})
/* Users Page */
app.get('/user/:cid', (req, res) => {
res.render('user', { cid: req.params.cid });
})
/* Events Page */
app.get('/events/', (req, res) => {
res.render('events');
})
/* Events View Page */
app.get('/event/:id', (req, res) => {
res.render('event', {id: req.params.id});
})
/* Events Analysis Page */
app.get('/analysis/:id', (req, res) => {
res.render('analysis', {id: req.params.id});
})
/* Patrons Page */
app.get('/patreon', (req, res) => {
res.render('patreon', {id: req.params.id});
})
app.get('/selfservice/events/request', (req, res) => {
res.redirect('https://api.simaware.ca/selfservice/events/request');
})
/* 404 Page */
app.use(function(req, res, next) {
res.status(404);
res.render('404', {layout: false});
});
app.listen(PORT, () => console.log(`Server started on port ${PORT}`));