-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathindex.js
32 lines (26 loc) · 944 Bytes
/
index.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
const express = require('express');
const compression = require('compression');
const favicon = require('serve-favicon');
const path = require('path');
const PORT = process.env.PORT || 5000;
/**
* Controllers (route handlers).
*/
const homeController = require('./controllers/home');
const worldController = require('./controllers/world');
/**
* Create Express server.
*/
const app = express();
app
.set('view engine', 'ejs')
.set('views', path.join(__dirname, 'views'))
.use(compression())
.use(express.static(path.join(__dirname, 'public')))
.use(favicon(path.join(__dirname, 'public/images', 'favicon.ico')))
// ---- ROUTES ---- //
.get('/', homeController.index)
.get('/world', worldController.index)
.get('/wiki', (req, res) => res.render('pages/wiki', { title: 'wiki' }))
.get('/about', (req, res) => res.render('pages/about', { title: 'about' }))
.listen(PORT, () => console.log(`Listening on ${PORT}`));