forked from ufosc/Club_Website_2
-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.js
33 lines (25 loc) · 811 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
require('dotenv').config()
const config = require('./config')
const express = require('express')
const rateLimit = require('express-rate-limit')
const CacheModule = require('./cache')
const app = express()
const http = require('http').createServer(app)
const cache = new CacheModule()
cache.start(config.cache_interval)
app.use(rateLimit(config.limiter))
app.set('view engine', 'ejs')
app.use(express.static('public'))
app.get('/', (req, res) => {
res.render('index', { page: 'index' })
})
app.get('/preview', (req, res) => {
res.render('temporary')
})
app.get(`/${config.admin_route}`, (req, res) => {
res.render('login')
})
app.get('/:page', (req, res) => {
res.render('index', { page: req.params.page })
})
http.listen(config.port, () => console.log(`Server running on port ${config.port}`))