-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathserver.js
More file actions
36 lines (30 loc) · 754 Bytes
/
server.js
File metadata and controls
36 lines (30 loc) · 754 Bytes
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
const express = require('express')
const nunjucks = require('nunjucks')
const path = require('path')
class App {
constructor() {
this.express = express()
this.isDev = process.env.NODE_ENV !== 'production'
this.middlewares()
this.views()
this.routes()
}
middlewares() {
this.express.use(express.urlencoded({
extended: false
}))
}
views() {
nunjucks.configure(path.resolve(__dirname, 'app', 'views'), {
watch: this.isDev,
express: this.express,
autoescape: true
})
this.express.use(express.static(path.resolve(__dirname, 'public')))
this.express.set('view engine', 'njk')
}
routes() {
this.express.use(require('./routes'))
}
}
module.exports = new App().express