-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
37 lines (26 loc) · 967 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
33
34
35
36
37
'use strict'
require('dotenv').config()
const express = require('express'),
app = express(),
server = require('http').createServer(app),
bodyParser = require('body-parser'),
cors = require('cors'),
path = require('path');
app.use(require('morgan')('dev'))
app.use(bodyParser.urlencoded({ extended: false }))
app.use(bodyParser.json())
app.use(cors())
let handlebars = require('express-handlebars').create({
layoutsDir: path.join(__dirname, "views/layouts"),
extname: 'hbs',
helpers: require('./helpers/handlebars-helpers') //only need this
});
app.engine('hbs', handlebars.engine);
app.set('view engine', 'hbs');
app.set('views', path.join(__dirname, "views"));
app.use('/', require('./routes/index'))
const host = process.env.host || '0.0.0.0'
const port = process.env.port || 3000
server.listen(port, host, () => {
console.log(`Express server available at http://${host}:${port}`)
})