forked from creativetechnologylab/checkout
-
Notifications
You must be signed in to change notification settings - Fork 2
/
app.js
48 lines (37 loc) · 1.45 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
require('dotenv-safe').config({allowEmptyValues: true});
const express = require('express')
const http = require('http')
const flash = require('express-flash-plus')
const helmet = require('helmet')
const {auth} = require('./src/js/authentication.js')
const sessions = require('./src/js/sessions.js')
const appLoader = require('./src/js/app-loader.js')
const templateLocals = require('./src/js/template-locals.js')
const errors = require('./src/js/errors.js')
const app = express()
const server = http.Server(app)
app.use(helmet())
// Static routes must come before sessions
app.use(express.static('./static'))
app.use('/bootstrap', express.static('./node_modules/bootstrap/dist'))
app.use('/buzz', express.static('./node_modules/buzz/dist'))
app.use('/clipboard', express.static('./node_modules/clipboard/dist'))
app.use('/jquery', express.static('./node_modules/jquery/dist'))
app.use('/fontawesome', express.static('./node_modules/@fortawesome/fontawesome-free'))
app.use('/moment', express.static('./node_modules/moment/min'))
app.use('/popper', express.static('./node_modules/@popperjs/core/dist/umd/'))
sessions(app)
auth(app)
app.use(flash())
// Use PUG to render pages
app.set('views', './src/views')
app.set('view engine', 'pug')
app.set('view cache', false)
// Load apps
app.use(templateLocals())
appLoader(app)
errors(app)
// Start server
const listener = server.listen(process.env.APP_PORT ,process.env.APP_HOST, function () {
console.log('Server started')
})