forked from bradtraversy/storybooks
-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.js
41 lines (32 loc) · 801 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
34
35
36
37
38
39
40
41
const path = require('path')
const express = require('express')
const dotenv = require('dotenv')
const morgan = require('morgan')
const exphbs = require('express-handlebars')
const connectDB = require('./config/db')
// Load config
dotenv.config({ path: './config/config.env' })
connectDB()
const app = express()
// Logging
if (process.env.NODE_ENV === 'development') {
app.use(morgan('dev'))
}
// Handlebars
app.engine(
'.hbs',
exphbs({
defaultLayout: 'main',
extname: '.hbs',
})
)
app.set('view engine', '.hbs')
// Static folder
app.use(express.static(path.join(__dirname, 'public')))
// Routes
app.use('/', require('./routes/index'))
const PORT = process.env.PORT || 3000
app.listen(
PORT,
console.log(`Server running in ${process.env.NODE_ENV} mode on port ${PORT}`)
)