-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.js
39 lines (32 loc) · 1.05 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
/** Import modules and init app */
const express = require(`express`);
const exphbs = require(`express-handlebars`);
const path = require(`path`);
const bodyParser = require(`body-parser`);
//keys = require('./config/keys');
/** Initialize App */
const app = express();
/** Load routes */
const routes = require(`./routes/index`);
/** Confirgure views engine */
/* global __dirname */
app.set(`views`, `${__dirname}/views`);
const hbs = exphbs.create({
defaultLayout: `main`,
layoutsDir: `${__dirname}/views/layouts`
});
app.engine(`handlebars`, hbs.engine);
app.set(`view engine`, `handlebars`);
/** Deliver static files */
app.use(express.static(path.join(__dirname, `/dist/public`)));
/** Configure Body parser to streamline HTTP requests */
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({
extended: true
}));
/** Use routes */
app.use(routes);
/** Set port and listen on that port */
/* global process */
app.set(`port`, (process.env.PORT || 5000));
app.listen(app.get(`port`), () => console.log(`App is running on port: ${app.get(`port`)}`));